7189103: Executors needs to maintain state
authorchegar
Thu, 16 Aug 2012 15:02:34 +0100
changeset 14214 aa16457b32df
parent 14213 91ba926457c6
child 14215 3ee2f6e24dbb
7189103: Executors needs to maintain state Reviewed-by: dholmes, hawtin
jdk/src/share/classes/java/util/concurrent/Executors.java
--- a/jdk/src/share/classes/java/util/concurrent/Executors.java	Wed Aug 15 15:31:30 2012 -0400
+++ b/jdk/src/share/classes/java/util/concurrent/Executors.java	Thu Aug 16 15:02:34 2012 +0100
@@ -530,18 +530,17 @@
                 return AccessController.doPrivileged(
                     new PrivilegedExceptionAction<T>() {
                         public T run() throws Exception {
-                            ClassLoader savedcl = null;
                             Thread t = Thread.currentThread();
-                            try {
-                                ClassLoader cl = t.getContextClassLoader();
-                                if (ccl != cl) {
-                                    t.setContextClassLoader(ccl);
-                                    savedcl = cl;
+                            ClassLoader cl = t.getContextClassLoader();
+                            if (ccl == cl) {
+                                return task.call();
+                            } else {
+                                t.setContextClassLoader(ccl);
+                                try {
+                                    return task.call();
+                                } finally {
+                                    t.setContextClassLoader(cl);
                                 }
-                                return task.call();
-                            } finally {
-                                if (savedcl != null)
-                                    t.setContextClassLoader(savedcl);
                             }
                         }
                     }, acc);