Andrea Cosentino created CAMEL-26776:
----------------------------------------
Summary: camel-support: Ensure KeyValueRepository instances
isolate namespaces across components and patterns
Key: CAMEL-26776
URL: https://issues.apache.org/jira/browse/CAMEL-26776
Project: Camel
Issue Type: Improvement
Components: camel-core
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.24.0
h3. Current behaviour
When multiple components and EIP patterns (such as {{camel-state-store}}, the
{{Cache}} EIP, {{KeyValueIdempotentRepository}}, and
{{KeyValueAggregationRepository}}) share a single {{KeyValueRepository}}
backend, keys from {{state-store}} and {{Cache}} EIP interact directly with the
root key-value store without namespace isolation.
Additionally, operations such as {{clear()}} and {{keys()}} on {{state-store}}
operate across the entire underlying repository rather than being scoped to the
specific store instance.
In {{KeyValueAggregationRepository}}, stored values are cast directly to
{{DefaultExchangeHolder}} during retrieval without verifying object type.
h3. Expected behaviour
Each component, named store, and pattern should operate within its own isolated
namespace on the underlying {{KeyValueRepository}}.
Operations like {{clear()}}, {{keys()}}, and {{size()}} should be strictly
scoped to their respective namespace so that entries belonging to one pattern
or store do not conflict with or affect another. Furthermore,
{{KeyValueAggregationRepository}} should safely verify object type before
unmarshalling stored entries.
h3. Change
* Introduce a {{NamespacedKeyValueRepository}} adapter in {{camel-support}}
that delegates to an underlying repository while scoping all key-value
operations ({{get}}, {{put}}, {{delete}}, {{contains}}, {{keys}}, {{clear}}) to
a specified prefix/namespace.
* Update {{StateStoreComponent}} to wrap backends in a namespaced repository
scoped to the store name.
* Update {{CacheReifier}} / {{CacheProcessor}} to namespace cache entries.
* Update {{KeyValueIdempotentRepository}} and {{KeyValueAggregationRepository}}
to use namespaced repository wrapping.
* In {{KeyValueAggregationRepository.unmarshallExchange}}, add type
verification before casting stored values.
* Add unit tests verifying namespace isolation across multiple stores and
patterns sharing a repository.
h3. Tests
* Unit tests in {{core/camel-support}} and {{components/camel-state-store}}
verifying that operations in one store or pattern do not affect, expose, or
clear keys in another store or pattern sharing the same repository.
* Ensure all existing tests in {{camel-support}}, {{camel-state-store}}, and
{{camel-core-processor}} pass cleanly.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)