Skip to content

Commit

Permalink
Merge branch '1.11.x' into 1.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Apr 24, 2024
2 parents 0501553 + ff16ad1 commit 5f2e16f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Expand Up @@ -89,7 +89,6 @@ public AnnotationHandler(BiConsumer<KeyValue, T> keyValueConsumer,
public void addAnnotatedParameters(T objectToModify, ProceedingJoinPoint pjp) {
try {
Method method = ((MethodSignature) pjp.getSignature()).getMethod();
method = pjp.getTarget().getClass().getDeclaredMethod(method.getName(), method.getParameterTypes());
List<AnnotatedParameter> annotatedParameters = AnnotationUtils.findAnnotatedParameters(annotationClass,
method, pjp.getArgs());
getAnnotationsFromInterfaces(pjp, method, annotatedParameters);
Expand Down
Expand Up @@ -454,6 +454,23 @@ void meterTagOnPackagePrivateMethod() {
assertThat(registry.get("method.timed").tag("foo", "bar").timer().count()).isEqualTo(1);
}

@Test
void meterTagOnSuperClass() {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
timedAspect.setMeterTagAnnotationHandler(meterTagAnnotationHandler);

AspectJProxyFactory pf = new AspectJProxyFactory(new MeterTagSub());
pf.setProxyTargetClass(true);
pf.addAspect(timedAspect);

MeterTagSub service = pf.getProxy();

service.superMethod("someValue");

assertThat(registry.get("method.timed").tag("superTag", "someValue").timer().count()).isEqualTo(1);
}

enum AnnotatedTestClass {

CLASS_WITHOUT_INTERFACE(MeterTagClass.class), CLASS_WITH_INTERFACE(MeterTagClassChild.class);
Expand Down Expand Up @@ -534,6 +551,22 @@ public void getAnnotationForArgumentToString(Long param) {

}

static class MeterTagSuper {

@Timed
public void superMethod(@MeterTag("superTag") String foo) {
}

}

static class MeterTagSub extends MeterTagSuper {

@Timed
public void subMethod(@MeterTag("subTag") String foo) {
}

}

}

private final class FailingMeterRegistry extends SimpleMeterRegistry {
Expand Down

0 comments on commit 5f2e16f

Please sign in to comment.