Prevent NPE if JNDI is disabled.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 19 Sep 2011 10:00:04 +0000 (10:00 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 19 Sep 2011 10:00:04 +0000 (10:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1172546 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/DefaultInstanceManager.java

index 9fc69ff..a542e3d 100644 (file)
@@ -179,13 +179,15 @@ public class DefaultInstanceManager implements InstanceManager {
         // At the end the postconstruct annotated
         // method is invoked
         List<AnnotationCacheEntry> annotations = annotationCache.get(clazz);
-        for (AnnotationCacheEntry entry : annotations) {
-            if (entry.getType() == AnnotationCacheEntryType.POST_CONSTRUCT) {
-                Method postConstruct = (Method) entry.getAccessibleObject();
-                boolean accessibility = postConstruct.isAccessible();
-                postConstruct.setAccessible(true);
-                postConstruct.invoke(instance);
-                postConstruct.setAccessible(accessibility);
+        if (annotations != null) {
+            for (AnnotationCacheEntry entry : annotations) {
+                if (entry.getType() == AnnotationCacheEntryType.POST_CONSTRUCT) {
+                    Method postConstruct = (Method) entry.getAccessibleObject();
+                    boolean accessibility = postConstruct.isAccessible();
+                    postConstruct.setAccessible(true);
+                    postConstruct.invoke(instance);
+                    postConstruct.setAccessible(accessibility);
+                }
             }
         }
     }