Bug 56611 - No need to call method.isAnnotationPresent() then call method.getAnnotation.
Summary: No need to call method.isAnnotationPresent() then call method.getAnnotation.
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.47
Hardware: All Mac OS X 10.4
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
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.