changeset 5448:4ed8c0b034c6

7189103: Executors needs to maintain state Reviewed-by: dholmes, hawtin
author chegar
date Mon, 20 Aug 2012 22:10:39 +0100
parents c867d446dca0
children 8067bdeb4e31
files src/share/classes/java/util/concurrent/Executors.java
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/util/concurrent/Executors.java	Wed Aug 15 10:57:28 2012 +0200
+++ b/src/share/classes/java/util/concurrent/Executors.java	Mon Aug 20 22:10:39 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);