< prev index next >

src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java

Print this page
*** 2216,22 ***
          final Thread t = Thread.currentThread();
          final ClassLoader old =  t.getContextClassLoader();
          if (defaultClassLoader != null)
              AccessController.doPrivileged(new PrivilegedAction<Void>() {
                  public Void run() {
!                     t.setContextClassLoader(defaultClassLoader);
                      return null;
                  }
              });
              return old;
      }
  
      @SuppressWarnings("removal")
      private void popDefaultClassLoader(final ClassLoader old) {
          AccessController.doPrivileged(new PrivilegedAction<Void>() {
              public Void run() {
!                 Thread.currentThread().setContextClassLoader(old);
                  return null;
              }
          });
      }
  
--- 2216,27 ---
          final Thread t = Thread.currentThread();
          final ClassLoader old =  t.getContextClassLoader();
          if (defaultClassLoader != null)
              AccessController.doPrivileged(new PrivilegedAction<Void>() {
                  public Void run() {
!                     if (t.getContextClassLoader() != defaultClassLoader) {
+                         t.setContextClassLoader(defaultClassLoader);
+                     }
                      return null;
                  }
              });
              return old;
      }
  
      @SuppressWarnings("removal")
      private void popDefaultClassLoader(final ClassLoader old) {
          AccessController.doPrivileged(new PrivilegedAction<Void>() {
              public Void run() {
!                 Thread t = Thread.currentThread();
+                 if (t.getContextClassLoader() != old) {
+                     t.setContextClassLoader(old);
+                 }
                  return null;
              }
          });
      }
  
< prev index next >