changeset 8534:998e4d7a514a

8174966: Unreferenced references Reviewed-by: smarks
author robm
date Tue, 21 Nov 2017 09:22:13 +0000
parents 86f6f2a70108
children 25909c2cebbd
files src/share/classes/sun/rmi/transport/Target.java
diffstat 1 files changed, 15 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/rmi/transport/Target.java	Thu Jul 20 15:08:31 2017 +0300
+++ b/src/share/classes/sun/rmi/transport/Target.java	Tue Nov 21 09:22:13 2017 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 import java.rmi.server.Unreferenced;
 import java.security.AccessControlContext;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.*;
 import sun.rmi.runtime.Log;
 import sun.rmi.runtime.NewThreadAction;
@@ -322,25 +323,21 @@
             Remote obj = getImpl();
             if (obj instanceof Unreferenced) {
                 final Unreferenced unrefObj = (Unreferenced) obj;
-                final Thread t =
-                    java.security.AccessController.doPrivileged(
-                        new NewThreadAction(new Runnable() {
+                final Thread t = AccessController.doPrivileged(
+                     new NewThreadAction(new Runnable() {
+                            @Override
                             public void run() {
-                                unrefObj.unreferenced();
+                                Thread.currentThread().setContextClassLoader(ccl);
+                                AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                                    @Override
+                                    public Void run() {
+                                        unrefObj.unreferenced();
+                                        return null;
+                                    }
+                                }, acc);
                             }
-                        }, "Unreferenced-" + nextThreadNum++, false, true));
-                // REMIND: access to nextThreadNum not synchronized; you care?
-                /*
-                 * We must manually set the context class loader appropriately
-                 * for threads that may invoke user code (see bugid 4171278).
-                 */
-                java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction<Void>() {
-                        public Void run() {
-                        t.setContextClassLoader(ccl);
-                        return null;
-                    }
-                });
+                    }, "Unreferenced-" + nextThreadNum++, false, true));
+                    // REMIND: access to nextThreadNum not synchronized; you care?
 
                 t.start();
             }