Federico Mariani created CAMEL-25346:
----------------------------------------

             Summary: camel-console - a dev console capacity set from 
configuration breaks the trace, receive, event and sql-trace consoles
                 Key: CAMEL-25346
                 URL: https://issues.apache.org/jira/browse/CAMEL-25346
             Project: Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 4.22.1, 4.18.4
            Reporter: Federico Mariani
             Fix For: 4.23.0


Camel Main applies {{camel.devConsole.<id>.*}} after resolving the console 
through the registry ({{BaseMainSupport.setDevConsoleProperties}}), and 
{{DefaultDevConsoleRegistry.register}} has already started it. {{doInit()}} 
therefore allocated the console buffers with the default capacity, while the 
console keeps using the configured {{capacity}} field:

* {{trace}} (default 100): the first dump fills the queue, every later dump 
fails with {{java.lang.IllegalStateException: Queue full}} 
({{TraceDevConsole.addMessage}}) - trace snapshots stop for the life of the 
application.
* {{receive}} (default 100): the same {{Queue full}}, thrown into the exchange 
of the received message.
* {{event}} (default 25): {{ArrayIndexOutOfBoundsException: Index 25 out of 
bounds for length 25}}, when recording events and on every dump.
* {{sql-trace}} (default 200): {{ArrayIndexOutOfBoundsException: Index 999 out 
of bounds for length 200}} on every dump.

Found while soak-testing Kaoto Kompanion with camel-cli-connector and 
{{-Dcamel.devConsole.trace.capacity=1000}}: the connector swallows the 
exception (logged at TRACE) and no more traces reach the tool.
{noformat}
java.lang.IllegalStateException: Queue full
    at java.util.AbstractQueue.add(AbstractQueue.java:98)
    at 
org.apache.camel.impl.console.TraceDevConsole.addMessage(TraceDevConsole.java:147)
    at 
org.apache.camel.impl.console.TraceDevConsole.doCallJson(TraceDevConsole.java:161)
    at 
org.apache.camel.support.console.AbstractDevConsole.call(AbstractDevConsole.java:115)
    at 
org.apache.camel.cli.connector.LocalCliConnector.callConsole(LocalCliConnector.java:1697)
{noformat}

Proposed fix: {{setCapacity}} resizes the buffers of a started console, keeping 
the newest entries, and the consoles index their buffers by their actual size. 
Defaults and the capacity validation in {{doInit}} are unchanged, so 
configurations that work today keep working.

_Claude Code on behalf of Croway_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to