Author: markt
Date: Tue Feb 23 22:07:00 2016
New Revision: 1731974

URL: http://svn.apache.org/viewvc?rev=1731974&view=rev
Log:
Partial fix for BZ 47214.
Refactor anonymous inner classes into named inner classes when they are 
referenced by name from elsewhere.
Modified:
    tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
    tomcat/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
    tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java

Modified: 
tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java?rev=1731974&r1=1731973&r2=1731974&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationContextFacade.java 
Tue Feb 23 22:07:00 2016
@@ -858,12 +858,8 @@ public class ApplicationContextFacade im
                    InvocationTargetException {
 
         if (SecurityUtil.isPackageProtectionEnabled()){
-           return AccessController.doPrivileged(new 
PrivilegedExceptionAction<Object>(){
-                @Override
-                public Object run() throws IllegalAccessException, 
InvocationTargetException{
-                    return method.invoke(context,  params);
-                }
-            });
+           return AccessController.doPrivileged(
+                   new PrivilegedExecuteMethod(method, context,  params));
         } else {
             return method.invoke(context, params);
         }
@@ -895,4 +891,23 @@ public class ApplicationContextFacade im
 
         throw realException;
     }
+
+
+    private static class PrivilegedExecuteMethod implements 
PrivilegedExceptionAction<Object> {
+
+        private final Method method;
+        private final ApplicationContext context;
+        private final Object[] params;
+
+        public PrivilegedExecuteMethod(Method method, ApplicationContext 
context, Object[] params) {
+            this.method = method;
+            this.context = context;
+            this.params = params;
+        }
+
+        @Override
+        public Object run() throws Exception {
+            return method.invoke(context, params);
+        }
+    }
 }

Modified: tomcat/trunk/java/org/apache/catalina/core/AsyncContextImpl.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/AsyncContextImpl.java?rev=1731974&r1=1731973&r2=1731974&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/AsyncContextImpl.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/AsyncContextImpl.java Tue Feb 23 
22:07:00 2016
@@ -221,20 +221,8 @@ public class AsyncContextImpl implements
                     (AsyncDispatcher) requestDispatcher;
             final ServletRequest servletRequest = getRequest();
             final ServletResponse servletResponse = getResponse();
-            Runnable run = new Runnable() {
-                @Override
-                public void run() {
-                    
request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, null);
-                    try {
-                        applicationDispatcher.dispatch(servletRequest, 
servletResponse);
-                    }catch (Exception x) {
-                        //log.error("Async.dispatch",x);
-                        throw new RuntimeException(x);
-                    }
-                }
-            };
-
-            this.dispatch = run;
+            this.dispatch = new AsyncRunnable(
+                    request, applicationDispatcher, servletRequest, 
servletResponse);
             this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH, 
null);
             clearServletRequestResponse();
         }
@@ -579,4 +567,33 @@ public class AsyncContextImpl implements
             coyoteRequest.action(ActionCode.DISPATCH_EXECUTE, null);
         }
     }
+
+
+    private static class AsyncRunnable implements Runnable {
+
+        private final AsyncDispatcher applicationDispatcher;
+        private final Request request;
+        private final ServletRequest servletRequest;
+        private final ServletResponse servletResponse;
+
+        public AsyncRunnable(Request request, AsyncDispatcher 
applicationDispatcher,
+                ServletRequest servletRequest, ServletResponse 
servletResponse) {
+            this.request = request;
+            this.applicationDispatcher = applicationDispatcher;
+            this.servletRequest = servletRequest;
+            this.servletResponse = servletResponse;
+        }
+
+        @Override
+        public void run() {
+            request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCHED, 
null);
+            try {
+                applicationDispatcher.dispatch(servletRequest, 
servletResponse);
+            }catch (Exception x) {
+                //log.error("Async.dispatch",x);
+                throw new RuntimeException(x);
+            }
+        }
+
+    }
 }

Modified: tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java?rev=1731974&r1=1731973&r2=1731974&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/security/SecurityClassLoad.java Tue 
Feb 23 22:07:00 2016
@@ -61,7 +61,7 @@ public final class SecurityClassLoad {
              "AccessLogAdapter");
         loader.loadClass
             (basePackage +
-             "ApplicationContextFacade$1");
+             "ApplicationContextFacade$PrivilegedExecuteMethod");
         loader.loadClass
             (basePackage +
              "ApplicationDispatcher$PrivilegedForward");
@@ -76,10 +76,10 @@ public final class SecurityClassLoad {
             "AsyncContextImpl");
         loader.loadClass
             (basePackage +
-            "AsyncContextImpl$DebugException");
+            "AsyncContextImpl$AsyncRunnable");
         loader.loadClass
             (basePackage +
-            "AsyncContextImpl$1");
+            "AsyncContextImpl$DebugException");
         loader.loadClass
             (basePackage +
             "AsyncListenerWrapper");



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to