[
https://issues.apache.org/jira/browse/CAMEL-27778?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-27778:
--------------------------------
Description:
Found while improving the option descriptions of camel-caffeine for CAMEL-23832
(commit
https://github.com/apache/camel/commit/6c50b5db2244cbdbc971efde5c64a537b5812e48,
pull request https://github.com/apache/camel/pull/31132).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. toD with ?keys= sets CamelCaffeineKeys to the single key
{{DefaultCaffeineSendDynamicAware.createPreProcessor}} removes {{keys}} from
the URI and then calls {{ex.getMessage().setHeader(CaffeineConstants.KEYS,
key)}}: it sets the {{key}} variable instead of {{keys}}. So a {{toD}} with
{{?keys=...}} gives GET_ALL / INVALIDATE_ALL the single key, or null.
Proposed change: pass {{keys}}.
h4. 2. caffeine-loadcache with createCacheIfNotExist and no cacheLoader fails
with a bare NullPointerException
{{CaffeineLoadCacheComponent.getOrCreateCache}} calls {{builder.build(null)}};
Caffeine then calls {{getClass()}} on the loader, so the endpoint fails to
start with an NPE that does not name the option.
Proposed change: check for a null cacheLoader first and throw an
IllegalArgumentException that names the option.
h4. 3. Keys stored by PUT_ALL cannot be read by GET or removed by INVALIDATE
{{getKey}} always converts {{CamelCaffeineKey}} to a String, while PUT_ALL
stores the Map keys as they are and GET_ALL / INVALIDATE_ALL use the
{{CamelCaffeineKeys}} Set as it is. An entry stored by PUT_ALL under a
non-String key (for example an Integer) is never found by GET or INVALIDATE.
Proposed change: do not convert the key to a String (behavior change), or
document it.
h4. 4. CamelCaffeineOldValue is never set
{{setResult}} is always called with a null old value, so the header is never
set. The description now says so.
Proposed change: have PUT return the old value through {{asMap().put}}, or
deprecate the header.
h4. 5. caffeine-loadcache does not clear its caches on shutdown
{{CaffeineLoadCacheComponent}} has no {{doShutdown}} that clears its caches,
unlike {{CaffeineCacheComponent}}.
_Claude Code on behalf of davsclaus_
was:
Found while improving the option descriptions of camel-caffeine for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31132).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. toD with ?keys= sets CamelCaffeineKeys to the single key
{{DefaultCaffeineSendDynamicAware.createPreProcessor}} removes {{keys}} from
the URI and then calls {{ex.getMessage().setHeader(CaffeineConstants.KEYS,
key)}}: it sets the {{key}} variable instead of {{keys}}. So a {{toD}} with
{{?keys=...}} gives GET_ALL / INVALIDATE_ALL the single key, or null.
Proposed change: pass {{keys}}.
h4. 2. caffeine-loadcache with createCacheIfNotExist and no cacheLoader fails
with a bare NullPointerException
{{CaffeineLoadCacheComponent.getOrCreateCache}} calls {{builder.build(null)}};
Caffeine then calls {{getClass()}} on the loader, so the endpoint fails to
start with an NPE that does not name the option.
Proposed change: check for a null cacheLoader first and throw an
IllegalArgumentException that names the option.
h4. 3. Keys stored by PUT_ALL cannot be read by GET or removed by INVALIDATE
{{getKey}} always converts {{CamelCaffeineKey}} to a String, while PUT_ALL
stores the Map keys as they are and GET_ALL / INVALIDATE_ALL use the
{{CamelCaffeineKeys}} Set as it is. An entry stored by PUT_ALL under a
non-String key (for example an Integer) is never found by GET or INVALIDATE.
Proposed change: do not convert the key to a String (behavior change), or
document it.
h4. 4. CamelCaffeineOldValue is never set
{{setResult}} is always called with a null old value, so the header is never
set. The description now says so.
Proposed change: have PUT return the old value through {{asMap().put}}, or
deprecate the header.
h4. 5. caffeine-loadcache does not clear its caches on shutdown
{{CaffeineLoadCacheComponent}} has no {{doShutdown}} that clears its caches,
unlike {{CaffeineCacheComponent}}.
_Claude Code on behalf of davsclaus_
> camel-caffeine: toD with keys sets the single key, loadcache without
> cacheLoader fails with an NPE, keys of PUT_ALL not found by GET
> ------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-27778
> URL: https://issues.apache.org/jira/browse/CAMEL-27778
> Project: Camel
> Issue Type: Bug
> Components: camel-caffeine
> Reporter: Claus Ibsen
> Priority: Minor
> Fix For: 4.25.0
>
>
> Found while improving the option descriptions of camel-caffeine for
> CAMEL-23832 (commit
> https://github.com/apache/camel/commit/6c50b5db2244cbdbc971efde5c64a537b5812e48,
> pull request https://github.com/apache/camel/pull/31132).
> These are separate problems of the component; the descriptions change only
> documents the current behavior.
> h4. 1. toD with ?keys= sets CamelCaffeineKeys to the single key
> {{DefaultCaffeineSendDynamicAware.createPreProcessor}} removes {{keys}} from
> the URI and then calls {{ex.getMessage().setHeader(CaffeineConstants.KEYS,
> key)}}: it sets the {{key}} variable instead of {{keys}}. So a {{toD}} with
> {{?keys=...}} gives GET_ALL / INVALIDATE_ALL the single key, or null.
> Proposed change: pass {{keys}}.
> h4. 2. caffeine-loadcache with createCacheIfNotExist and no cacheLoader fails
> with a bare NullPointerException
> {{CaffeineLoadCacheComponent.getOrCreateCache}} calls
> {{builder.build(null)}}; Caffeine then calls {{getClass()}} on the loader, so
> the endpoint fails to start with an NPE that does not name the option.
> Proposed change: check for a null cacheLoader first and throw an
> IllegalArgumentException that names the option.
> h4. 3. Keys stored by PUT_ALL cannot be read by GET or removed by INVALIDATE
> {{getKey}} always converts {{CamelCaffeineKey}} to a String, while PUT_ALL
> stores the Map keys as they are and GET_ALL / INVALIDATE_ALL use the
> {{CamelCaffeineKeys}} Set as it is. An entry stored by PUT_ALL under a
> non-String key (for example an Integer) is never found by GET or INVALIDATE.
> Proposed change: do not convert the key to a String (behavior change), or
> document it.
> h4. 4. CamelCaffeineOldValue is never set
> {{setResult}} is always called with a null old value, so the header is never
> set. The description now says so.
> Proposed change: have PUT return the old value through {{asMap().put}}, or
> deprecate the header.
> h4. 5. caffeine-loadcache does not clear its caches on shutdown
> {{CaffeineLoadCacheComponent}} has no {{doShutdown}} that clears its caches,
> unlike {{CaffeineCacheComponent}}.
> _Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)