The main ASF Bugzilla instance will be unavailable for 4 hours starting 19.00 UTC 2016-10-29 for an upgrade to 5.0.3
Bug 56611 - No need to call method.isAnnotationPresent() then call method.getAnnotation.
No need to call method.isAnnotationPresent() then call method.getAnnotation.
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
All Mac OS X 10.4
: P2 enhancement (vote)
: ---
Assigned To: Tomcat Developers Mailing List
Depends on:
  Show dependency tree
Reported: 2014-06-10 08:36 UTC by Mou, Jian
Modified: 2014-06-19 20:46 UTC (History)
0 users

org.apache.catalina.core.DefaultInstanceManager (8.11 KB, patch)
2014-06-10 08:36 UTC, Mou, Jian
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.