Claus Ibsen created CAMEL-27766:
-----------------------------------
Summary: camel-support - KeyValueRepository size() has
@ManagedAttribute, so registering it as an MBean fails with a WARN
Key: CAMEL-27766
URL: https://issues.apache.org/jira/browse/CAMEL-27766
Project: Camel
Issue Type: Bug
Components: camel-support, camel-core
Reporter: Claus Ibsen
Fix For: 4.25.0
{{size()}} of the KeyValueRepository implementations has {{@ManagedAttribute}},
but it is not a Java bean getter. The JMX assembler rejects it, so a repository
is not registered as an MBean. When a route calls the repository with {{bean}},
Camel logs a WARN with a stack trace at startup:
{noformat}
WARN ... JmxManagementLifecycleStrategy : Could not register service:
BeanProcessor[org.apache.camel.support.MemoryKeyValueRepository(0x1b1e1f02)#size]
as Service MBean.
java.lang.IllegalArgumentException: @ManagedAttribute can only be used on Java
bean methods, was: public int
org.apache.camel.support.MemoryKeyValueRepository.size() on bean: class
org.apache.camel.support.MemoryKeyValueRepository
{noformat}
The route still works. All 11 implementations on main have it:
MemoryKeyValueRepository (camel-support), and the ones in camel-caffeine,
camel-cassandraql, camel-ehcache, camel-hazelcast, camel-infinispan,
camel-jcache, camel-jpa, camel-kafka, camel-redis and camel-sql.
Reproduce with Camel 4.23.0 and {{camel run}}:
{code:yaml}
- beans:
- name: store
type: org.apache.camel.support.MemoryKeyValueRepository
- route:
id: kv
from:
uri: timer:a
parameters:
repeatCount: 1
steps:
- bean:
ref: store
method: size
- log: "size ${body}"
{code}
A fix: use {{@ManagedOperation}} on {{size()}}, or add a getter such as
{{getSize()}} with {{@ManagedAttribute}}, as MemoryIdempotentRepository does
with {{getCacheSize()}}. Found when building the route/cache example in
camel-jbang-examples, where the route removes a customer from the cache with a
{{bean}} call.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)