Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
AnnotationUtils.getValue() may hide relevant errors [SPR-15481] #20041
At the core of the issue are AliasFor type annotations which are synthesized into a proxy with SynthesizedAnnotationInvocationHandler which delegates to AbstractAliasAwareAnnotationAttributeExtractor.getAttributeValue(..) to get the actual annotation value. When it sees that this annotation is synthesized and has alias value mismatch it results in InvocationtargetException which is trapped inside of AnnotationUtils.getValue() operation which simply return null. This can and most likely will result in subsequent error downstream, but the error message may be misleading (see https://jira.spring.io/browse/INT-4263)
IMHO, while I do believe that the initial intention of returning null for non existing attributes should stay, I also believe that we should trap InvocationTargetException and re-throw. While that may result in breaking change, it's one of those where it's for the good cause.
Oleg Zhurakousky commented
Basically the idea is to catch InvocationTargetException see if its target is AnnotationConfigurationException and if so re-throw it. I actually noticed that we're already doing that in several other related operations, which made it a bit easier by delegating to already existing rethrowAnnotationConfigurationException(..);