Serdar Gökay created CAMEL-25625:
------------------------------------
Summary: camel-console - Processor dev console fails with HTTP 500
for a to(log) with groupInterval or groupSize
Key: CAMEL-25625
URL: https://issues.apache.org/jira/browse/CAMEL-25625
Project: Camel
Issue Type: Bug
Components: camel-core, camel-management
Affects Versions: 4.22.1
Environment: Camel JBang 4.22.1, Java 21.0.12, macOS; also Camel
4.22.1 on Kubernetes
Reporter: Serdar Gökay
The processor dev console fails with HTTP 500 when a route sends to a {{log}}
endpoint in throughput mode ({{groupInterval}} or {{groupSize}}). Each call of
{{/q/dev/processor}} logs an unhandled exception, so a tool that polls the
console fills the log with it, and the statistics of every other processor in
the application are not returned either.
h3. Reproduce
Camel JBang 4.22.1 with this route:
{noformat}
- route:
id: throughput
from:
uri: timer:tick
parameters:
period: 500
steps:
- to:
id: plain-log
uri: log:plain
- to:
id: throughput-log
uri: log:throughput
parameters:
groupInterval: 5000
{noformat}
{noformat}
camel run throughput.camel.yaml --console --port=28765 --management-port=28766
curl -H 'Accept: application/json' http://localhost:28766/q/dev/processor
{noformat}
Expected: HTTP 200 with the processors of the route.
Actual: HTTP 500 and each call logs:
{noformat}
ERROR io.vertx.ext.web.RoutingContext : Unhandled exception in router
java.lang.reflect.UndeclaredThrowableException
at jdk.proxy2/jdk.proxy2.$Proxy54.getDestination(Unknown Source)
at
org.apache.camel.impl.console.ProcessorDevConsole.getDestination(ProcessorDevConsole.java:324)
at
org.apache.camel.impl.console.ProcessorDevConsole.includeProcessorsJSon(ProcessorDevConsole.java:306)
at
org.apache.camel.impl.console.ProcessorDevConsole.includeProcessorsJson(ProcessorDevConsole.java:234)
at
org.apache.camel.impl.console.ProcessorDevConsole.doCallJson(ProcessorDevConsole.java:204)
at
org.apache.camel.support.console.AbstractDevConsole.call(AbstractDevConsole.java:108)
at
org.apache.camel.component.platform.http.main.ManagementHttpServer$6.lambda$handle$2(ManagementHttpServer.java:1142)
Caused by: javax.management.AttributeNotFoundException: getAttribute failed:
ModelMBeanAttributeInfo not found for Destination
at
java.management/javax.management.modelmbean.RequiredModelMBean.getAttribute(RequiredModelMBean.java:1380)
at
java.management/javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:273)
{noformat}
Without the {{groupInterval}} parameter the same route returns HTTP 200.
h3. Cause
For a {{to}} whose endpoint is a {{LogEndpoint}} with a {{ThroughputLogger}},
{{DefaultManagementObjectStrategy}} registers a {{ManagedThroughputLogger}}
instead of a {{ManagedSendProcessor}}. {{ManagedThroughputLogger}} has no
{{Destination}} attribute. {{ProcessorDevConsole.getDestination}} selects
processors by name ({{to}}, {{toD}}, {{enrich}}, ...) and asks
{{ManagedCamelContext.getManagedProcessor(id, ManagedDestinationAware.class)}}
for a proxy. That method creates a JMX proxy for the requested interface
without checking that the MBean implements it, so it never returns null for
this case and the proxy call fails.
Code: [ProcessorDevConsole,
4.22.1|https://github.com/apache/camel/blob/camel-4.22.1/core/camel-console/src/main/java/org/apache/camel/impl/console/ProcessorDevConsole.java#L316-L328],
[ManagedCamelContextImpl,
4.22.1|https://github.com/apache/camel/blob/camel-4.22.1/core/camel-management/src/main/java/org/apache/camel/management/ManagedCamelContextImpl.java#L57-L72],
[DefaultManagementObjectStrategy,
4.22.1|https://github.com/apache/camel/blob/camel-4.22.1/core/camel-management/src/main/java/org/apache/camel/management/DefaultManagementObjectStrategy.java#L468-L476].
The same code is on main: [ProcessorDevConsole,
main|https://github.com/apache/camel/blob/main/core/camel-console/src/main/java/org/apache/camel/impl/console/ProcessorDevConsole.java#L341-L353].
h3. Proposed change
Let {{ManagedThroughputLogger}} expose the {{Destination}} attribute (the log
endpoint URI), so the console shows the URI of this {{to}} like any other.
Alternatively, {{ProcessorDevConsole.getDestination}} could skip MBeans that do
not provide the attribute.
We came across this when a monitoring tool that polls {{/q/dev/processor}} kept
logging the error for an application that measures throughput with
{{log:...?groupInterval=...}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)