[
https://issues.apache.org/jira/browse/CAMEL-27804?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27804:
--------------------------------
Description:
Found while improving the option descriptions of camel-ehcache for CAMEL-23832
(commit
https://github.com/apache/camel/commit/800e63636cb5cf151e93037191c087b49ed30169,
pull request https://github.com/apache/camel/pull/31138).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. The key is converted only when keyType is set, and the key option never
{{EhcacheProducer.getKey}} converts CamelEhcacheKey only when the keyType
option is set, not when the key type comes from a CacheConfiguration, while the
value uses the cache's runtime type. The default {{key}} option is never
converted, so {{key=1&keyType=java.lang.Long}} passes the String "1" and
Ehcache throws ClassCastException ("Invalid key type").
Proposed change: convert with {{cache.getRuntimeConfiguration().getKeyType()}}
for both the header and the option.
h4. 2. REPLACE and PUT_IF_ABSENT report success when nothing changed
Ehcache's replace(key, value) does nothing when the key is absent, but
CamelEhcacheActionSucceeded is still true; PUT_IF_ABSENT reports success when
the key already existed.
Proposed change: success = whether the cache changed.
h4. 3. PUT_ALL casts the value header without conversion
onPutAll casts the CamelEhcacheValue header to Map; a non-Map value gives
ClassCastException.
h4. 4. A typed cache fails without keyType/valueType
Without keyType, valueType and a configuration, {{EhcacheManager.getCache}}
asks for <Object,Object>, and a cache already in the CacheManager with other
types (for example from configurationUri XML) fails with
IllegalArgumentException.
Proposed change: use the existing cache's runtime types.
_Claude Code on behalf of davsclaus_
was:
Found while improving the option descriptions of camel-ehcache for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31138).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. The key is converted only when keyType is set, and the key option never
{{EhcacheProducer.getKey}} converts CamelEhcacheKey only when the keyType
option is set, not when the key type comes from a CacheConfiguration, while the
value uses the cache's runtime type. The default {{key}} option is never
converted, so {{key=1&keyType=java.lang.Long}} passes the String "1" and
Ehcache throws ClassCastException ("Invalid key type").
Proposed change: convert with {{cache.getRuntimeConfiguration().getKeyType()}}
for both the header and the option.
h4. 2. REPLACE and PUT_IF_ABSENT report success when nothing changed
Ehcache's replace(key, value) does nothing when the key is absent, but
CamelEhcacheActionSucceeded is still true; PUT_IF_ABSENT reports success when
the key already existed.
Proposed change: success = whether the cache changed.
h4. 3. PUT_ALL casts the value header without conversion
onPutAll casts the CamelEhcacheValue header to Map; a non-Map value gives
ClassCastException.
h4. 4. A typed cache fails without keyType/valueType
Without keyType, valueType and a configuration, {{EhcacheManager.getCache}}
asks for <Object,Object>, and a cache already in the CacheManager with other
types (for example from configurationUri XML) fails with
IllegalArgumentException.
Proposed change: use the existing cache's runtime types.
_Claude Code on behalf of davsclaus_
> camel-ehcache: the key is not converted, REPLACE and PUT_IF_ABSENT report
> success when nothing changed
> ------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27804
> URL: https://issues.apache.org/jira/browse/CAMEL-27804
> Project: Camel
> Issue Type: Bug
> Components: camel-ehcache
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-ehcache for
> CAMEL-23832 (commit
> https://github.com/apache/camel/commit/800e63636cb5cf151e93037191c087b49ed30169,
> pull request https://github.com/apache/camel/pull/31138).
> These are separate problems of the component; the descriptions change only
> documents the current behavior.
> h4. 1. The key is converted only when keyType is set, and the key option never
> {{EhcacheProducer.getKey}} converts CamelEhcacheKey only when the keyType
> option is set, not when the key type comes from a CacheConfiguration, while
> the value uses the cache's runtime type. The default {{key}} option is never
> converted, so {{key=1&keyType=java.lang.Long}} passes the String "1" and
> Ehcache throws ClassCastException ("Invalid key type").
> Proposed change: convert with
> {{cache.getRuntimeConfiguration().getKeyType()}} for both the header and the
> option.
> h4. 2. REPLACE and PUT_IF_ABSENT report success when nothing changed
> Ehcache's replace(key, value) does nothing when the key is absent, but
> CamelEhcacheActionSucceeded is still true; PUT_IF_ABSENT reports success when
> the key already existed.
> Proposed change: success = whether the cache changed.
> h4. 3. PUT_ALL casts the value header without conversion
> onPutAll casts the CamelEhcacheValue header to Map; a non-Map value gives
> ClassCastException.
> h4. 4. A typed cache fails without keyType/valueType
> Without keyType, valueType and a configuration, {{EhcacheManager.getCache}}
> asks for <Object,Object>, and a cache already in the CacheManager with other
> types (for example from configurationUri XML) fails with
> IllegalArgumentException.
> Proposed change: use the existing cache's runtime types.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)