-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support JAX-RS Annotation Inheritance #1098
Conversation
This demonstrates a matching failure in our current instrumentation.
6619e4d
to
aa46e81
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
I think we're likely to optimize the matching process later.
But for now, JAX-RS supports inheritance in its semantics, so I think we should, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is definitely room for optimization (not traversing the tree excessively) but I don't see anything that should block getting this into users hands.
* <p>6. Superclass's superclass | ||
* | ||
* <p>... | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be good to reference where in jax-rs this precedence order can be found since presumably this follows that implementation
This pull request add support for jax-rs annotations on a parent class or interface.
1. ByteBuddy ElementMatcher
hasSuperMethod
is a newElementMatcher
that matches on a method or its definitions in any superclass or interface. This allows ByteBuddy to match a JAX-RS annotation on an implemented interface or superclass rather than just the concrete class. The performance impact should be minimal because the TypeMatcher for the instrumentation has to match first anyway. The TypeMatcher is unchanged.2. A class hierarchy iterator
A deterministic iterator that walks a class's supertypes and implemented interfaces in a breadth-first manner.
3. Resource naming using the iterator
In
JaxRsAnnotationsDecorator
, we use the iterator to find the@Path
annotation on the class as well as the relevant@Path
andHttpMethod
annotations on the method.4. Updated Tests
Some new tests were added and previous tests updated to account for annotations at different levels of the hierarchy. Some old tests were incorrect in that they didn't account for annotation inheritance. Additionally, the commented-out tests that relied on Java 8 were manually checked to ensure no regressions versus #1061