Federico Mariani created CAMEL-24076:
----------------------------------------
Summary: camel-jms: browseLimit URI option is dead - browsing is
unlimited despite the documented default of 100 (CAMEL-21183 follow-up)
Key: CAMEL-24076
URL: https://issues.apache.org/jira/browse/CAMEL-24076
Project: Camel
Issue Type: Bug
Components: camel-jms
Affects Versions: 4.21.0
Reporter: Federico Mariani
Attachments: JmsBrowseLimitOptionTest.java
h3. Problem
The {{@UriParam browseLimit}} (default 100 in the catalog/docs,
JmsConfiguration.java:578-580) binds via the generated configurer to
{{JmsConfiguration.setBrowseLimit()}} - which *nothing ever reads*. Browsing
actually uses {{JmsQueueEndpoint.maximumBrowseSize}} (default {{-1}}), and
{{DefaultQueueBrowseStrategy}} maps {{limit <= 0}} to {{Integer.MAX_VALUE}}.
CAMEL-21183 (26dc7199cc96) added {{browseLimit=100}} and set
{{maximumBrowseSize=100}} to match; the immediately following commit
(caa51c5da0a8) reverted {{maximumBrowseSize}} to {{-1}} while refactoring the
limit into a method parameter, orphaning the config field -
{{configuration.getBrowseLimit()}} was never wired into the endpoint.
h3. Failure scenario
{{jms:queue:big?browseLimit=10}} browsed via JMX {{ManagedBrowsableEndpoint}}
or the developer console -> the option is silently ignored and
{{getExchanges()}} materializes the *entire queue* into memory (OOM risk on
deep queues), contradicting the documented default of 100. The same pattern is
inherited by camel-activemq/camel-activemq6 queue endpoints.
{{BrowsableQueueTest}} uses the undocumented {{maximumBrowseSize}} parameter
(bound via reflection fallback), pinning nothing about {{browseLimit}}.
h3. Suggested fix direction
Wire {{configuration.getBrowseLimit()}} into {{JmsQueueEndpoint}} at creation
time (note {{JmsQueueEndpoint.setBrowseLimit}} already maps to
{{maximumBrowseSize}} - the configurer just targets the configuration object
instead of the endpoint), and align the actual default with the documented one
(100).
h3. Reproducer
Attached {{JmsBrowseLimitOptionTest.java}} (place in
{{components/camel-jms/src/test/java/org/apache/camel/component/jms/}}): sends
8 messages, browses with {{?browseLimit=6}}, gets 8 back and
{{getBrowseLimit()}} returns -1.
----
_This issue was researched and filed by Claude Code on behalf of [~croway]
(GitHub: Croway), as part of a deep code review of camel-jms and camel-amqp. A
failing JUnit reproducer is attached; it fails deterministically on current
main (4.22.0-SNAPSHOT)._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)