[
https://issues.apache.org/jira/browse/CAMEL-23840?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Claus Ibsen updated CAMEL-23840:
--------------------------------
Affects Version/s: 4.21.0
> pollEnrich with cacheSize(-1) does not disable consumer cache (dynamic
> endpoints)
> ---------------------------------------------------------------------------------
>
> Key: CAMEL-23840
> URL: https://issues.apache.org/jira/browse/CAMEL-23840
> Project: Camel
> Issue Type: Bug
> Components: came-core
> Affects Versions: 4.14.6, 4.20.0, 4.21.0
> Reporter: Mark Snijder
> Priority: Minor
> Fix For: 4.18.4, 4.22.0
>
> Attachments: reproduce-camel-pollenrich-cache-issue-main.zip,
> visualvm-monitor.png, visualvm-threads.png
>
>
> Hi!
> I found out about this issue with _pollEnrich_ because we had a memory issue
> with the SFTP component because we did not set the cache size so it defaulted
> to 1000. So I read the documentation and set it to cachesize to -1, but the
> memory still kept going up.
> Our code was using dynamic endpoints that triggered this.
> When _.pollEnrich().cacheSize(-1)_ is used, the documented intent is to
> disable the consumer cache entirely.
> This mirrors how _DefaultProducerCache_ (via {_}EmptyProducerCache{_})
> already works on the producer side for {_}cacheSize(-1){_}.
> However, this is broken. The _PollEnricher.doBuild()_ method unconditionally
> creates a DefaultConsumerCache regardless of cacheSize, and
> DefaultConsumerCache normalizes any cacheSize <= 0 to the CamelContext
> maximum cache pool size (default 1000):
> {code:java}
> // DefaultConsumerCache constructor (line 55)
> this.maxCacheSize = cacheSize <= 0 ?
> CamelContextHelper.getMaximumCachePoolSize(camelContext) : cacheSize;
> {code}
> As a result, even with cacheSize(-1), polling consumers are retained in an
> the cache of up to 1000 entries instead of being discarded.
> PollEnricher.doBuild() creates the DefaultConsumerCache unconditionally, and
> DefaultConsumerCache re-interprets negative cache sizes as "use the context
> maximum."
> Reproducer available (and also attached as zip):
> [https://github.com/msnijder30/reproduce-camel-pollenrich-cache-issue]
>
> Atleast present since camel 4.14.x and also reproducable in camel 4.20.x, not
> sure since how much earlier this bug is present.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)