Fix some test failures.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 9 Mar 2011 14:48:29 +0000 (14:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 9 Mar 2011 14:48:29 +0000 (14:48 +0000)
Don't use load() since that creates a whole bunch of edge cases that need to be handled.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1079819 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/StandardWrapper.java

index 40b1e89..cca942f 100644 (file)
@@ -1089,7 +1089,7 @@ public class StandardWrapper extends ContainerBase
                 }
             }
 
-            processServletSecurityAnnotation(servlet);
+            processServletSecurityAnnotation(servlet.getClass());
 
             // Special handling for ContainerServlet instances
             if ((servlet instanceof ContainerServlet) &&
@@ -1129,19 +1129,26 @@ public class StandardWrapper extends ContainerBase
 
     /**
      * {@inheritDoc}
+     * @throws ClassNotFoundException 
      */
     @Override
     public void servletSecurityAnnotationScan() throws ServletException {
         if (instance == null) {
-            load();
+            Class<?> clazz = null;
+            try {
+                clazz = getParentClassLoader().loadClass(getServletClass());
+                processServletSecurityAnnotation(clazz);
+            } catch (ClassNotFoundException e) {
+                // Safe to ignore. No class means no annotations to process
+            }
         } else {
             if (servletSecurityAnnotationScanRequired) {
-                processServletSecurityAnnotation(instance);
+                processServletSecurityAnnotation(instance.getClass());
             }
         }
     }
 
-    private void processServletSecurityAnnotation(Servlet servlet) {
+    private void processServletSecurityAnnotation(Class<?> clazz) {
         // Calling this twice isn't harmful so no syncs
         servletSecurityAnnotationScanRequired = false;
 
@@ -1152,7 +1159,7 @@ public class StandardWrapper extends ContainerBase
         }
 
         ServletSecurity secAnnotation =
-            servlet.getClass().getAnnotation(ServletSecurity.class);
+            clazz.getAnnotation(ServletSecurity.class);
         if (secAnnotation != null) {
             ctxt.addServletSecurity(
                     new ApplicationServletRegistration(this, ctxt),