Bug 56611

Summary: No need to call method.isAnnotationPresent() then call method.getAnnotation.
Product: Tomcat 7 Reporter: Mou, Jian <jianpro>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Severity: enhancement    
Priority: P2    
Version: 7.0.47   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X 10.4   
Attachments: org.apache.catalina.core.DefaultInstanceManager

Description Mou, Jian 2014-06-10 08:36:41 UTC
Created attachment 31702 [details]

Just call method.getAnnotation(EJB.class) once, since isAnnotationPresent is also implmented by calling getAnnotation. 

    public boolean isAnnotationPresent(
        Class<? extends Annotation> annotationClass) {
        return getAnnotation(annotationClass) != null;
Comment 1 Mark Thomas 2014-06-18 19:22:13 UTC
Thanks for the patch.

It has been applied )with slight tweaks for formatting) to 8.0.x for 8.0.9 onwards and to 7.0.x for 7.0./55 onwards. I also fixed all the additional instances of the same problem elsewhere in the code base.
Comment 2 Konstantin Kolinko 2014-06-19 20:46:37 UTC
I fixed several other usages of isAnnotationPresent() method, missed by Mark.
It will be in 8.0.10, 7.0.55 onwards.