river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r1599203 - in /river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini: thread/ThreadPool.java tool/PreferredListGen.java
Date Mon, 02 Jun 2014 12:59:25 GMT
Author: peter_firmstone
Date: Mon Jun  2 12:59:24 2014
New Revision: 1599203

URL: http://svn.apache.org/r1599203
Log:
Changed PreferredListGen to catch a NoClassDefFoundError, print message to System.err and
continue.  Sometimes classes found are not available as they are in external libraries, this
shouldn't stop PreferredListGen from working.

Altered registering ThreadPool's shutdown hook to be performed from privileged context.

Modified:
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java
    river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/PreferredListGen.java

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java?rev=1599203&r1=1599202&r2=1599203&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/thread/ThreadPool.java Mon Jun  2
12:59:24 2014
@@ -20,6 +20,7 @@ package com.sun.jini.thread;
 
 import com.sun.jini.action.GetLongAction;
 import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.RejectedExecutionException;
@@ -133,25 +134,31 @@ final class ThreadPool implements Execut
         queue = new LinkedBlockingQueue<Runnable>();
         workerCount = new AtomicInteger();
         availableThreads = new AtomicInteger();
-        
 //         Thread not started until after constructor completes
 //         this escaping occurs safely.
-        Runtime.getRuntime().addShutdownHook(new Thread ("ThreadPool destroy"){
+        AccessController.doPrivileged(new PrivilegedAction(){
+
             @Override
-            public void run (){
-                try {
-                    // Allow four seconds prior to shutdown for other
-                    // processes to complete.
-                    Thread.sleep(4000L);
-                } catch (InterruptedException ex) {
-                    Thread.currentThread().interrupt();
-                }
-                shutdown = true;
-                Thread [] threads = new Thread [workerCount.get() + 1 ];
-                int count = threadGroup.enumerate(threads);
-                for (int i = 0; i < count; i++){
-                    threads [i].interrupt();
-                }
+            public Object run() {
+                Runtime.getRuntime().addShutdownHook(new Thread ("ThreadPool destroy"){
+                    @Override
+                    public void run (){
+                        try {
+                            // Allow four seconds prior to shutdown for other
+                            // processes to complete.
+                            Thread.sleep(4000L);
+                        } catch (InterruptedException ex) {
+                            Thread.currentThread().interrupt();
+                        }
+                        shutdown = true;
+                        Thread [] threads = new Thread [workerCount.get() + 1 ];
+                        int count = threadGroup.enumerate(threads);
+                        for (int i = 0; i < count; i++){
+                            threads [i].interrupt();
+                        }
+                    }
+                });
+                return null;
             }
         });
     }

Modified: river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/PreferredListGen.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/PreferredListGen.java?rev=1599203&r1=1599202&r2=1599203&view=diff
==============================================================================
--- river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/PreferredListGen.java (original)
+++ river/jtsk/skunk/qa_refactor/trunk/src/com/sun/jini/tool/PreferredListGen.java Mon Jun
 2 12:59:24 2014
@@ -1066,7 +1066,11 @@ public class PreferredListGen {
 	    if (!listGraph.setPreferred(clazz, false, false)) {
 		return;
 	    }
-	    inspectClass(clazz);
+            try {
+                inspectClass(clazz);
+            } catch (NoClassDefFoundError e){
+                System.err.println(e.toString());
+            }
 	}
     }
 



Mime
View raw message