Skip to content

Commit

Permalink
Fixes #10442 - Reduce verbosity when JMX finds overloaded setter
Browse files Browse the repository at this point in the history
Now the log statement is only emitted when there is no matching setter method, but a mismatched one exists.

Signed-off-by: Simone Bordet <[email protected]>
  • Loading branch information
sbordet committed Aug 31, 2023
1 parent d09a95a commit 1ca52ef
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,25 +445,24 @@ private Method findSetter(ManagedAttribute attribute, Method getter, String name
setterName = "set" + name.substring(0, 1).toUpperCase(Locale.ENGLISH) + name.substring(1);

Method setter = null;
Method candidate = null;
Class<?> klass = getter.getDeclaringClass();
for (Method method : klass.getMethods())
{
if (method.getName().equals(setterName) && method.getParameterCount() == 1)
{
if (setter != null)
candidate = method;
if (getter.getReturnType().equals(method.getParameterTypes()[0]))
{
LOG.info("Multiple setters for mbean attribute {} in {}", name, klass);
continue;
}
if (!getter.getReturnType().equals(method.getParameterTypes()[0]))
{
LOG.info("Getter/setter type mismatch for mbean attribute {} in {}", name, klass);
continue;
setter = method;
break;
}
setter = method;
}
}

if (candidate != null && setter == null)
LOG.info("Getter/setter type mismatch for mbean attribute {} in {}, attribute will be read-only", name, klass);

return setter;
}

Expand Down

0 comments on commit 1ca52ef

Please sign in to comment.