You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
When I try to config metrics-spring using JavaConfig and add @Gauge and @CachedGauge annotation on methods, I can't get their metric info through jmx. Other annotations like @counted, @metered, @timed work well. I looked into the source code, and find some problem that may be bugs.
In GaugeMethodAnnotationBeanPostProcessor line 28, the "return ReflectionUtils.invokeMethod(method, bean); " statement throw out java.lang.IllegalArgumentException: object is not an instance of declaring class. To my understanding, the argument bean is a proxy object, while method is the original Method object of the proxy target. We can't just call method like this. One simple solution is to find out the proxy object's corresponding Method and call it like this:
CachedGaugeAnnotationBeanPostProcessor class has the same problem and can be fixed in the same way.
The text was updated successfully, but these errors were encountered:
segeon
changed the title
@Gauge and @CachedGauge annotation do not work on methods
@Gauge and @CachedGauge annotation do not work properly on methods when using JavaConfig
Sep 21, 2015
When I try to config metrics-spring using JavaConfig and add @Gauge and @CachedGauge annotation on methods, I can't get their metric info through jmx. Other annotations like @counted, @metered, @timed work well. I looked into the source code, and find some problem that may be bugs.
In GaugeMethodAnnotationBeanPostProcessor line 28, the "return ReflectionUtils.invokeMethod(method, bean); " statement throw out java.lang.IllegalArgumentException: object is not an instance of declaring class. To my understanding, the argument bean is a proxy object, while method is the original Method object of the proxy target. We can't just call method like this. One simple solution is to find out the proxy object's corresponding Method and call it like this:
return ReflectionUtils.invokeMethod(bean.getClass().getMethod(method.getName(), method.parameterTypes), bean);
CachedGaugeAnnotationBeanPostProcessor class has the same problem and can be fixed in the same way.
The text was updated successfully, but these errors were encountered: