You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2007/01/30 22:35:16 UTC

svn commit: r501578 - in /portals/jetspeed-2/trunk/components: portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java security/src/java/org/apache/jetspeed/security/SecurityHelper.java

Author: taylor
Date: Tue Jan 30 13:35:16 2007
New Revision: 501578

URL: http://svn.apache.org/viewvc?view=rev&rev=501578
Log:
1. Fix bug with Tomcat not shutting down properly
2. Add safe checks for null in SecurityHelper because of bug logged by Andrew Hall

For the Tomcat shutdown, there are two issues:
- One we see a message in the console 
"INFO: Failed shutdown of Apache Portable Runtime"
- The second is that Tomcat in fact doesn't shutdown completely. Either the
console remains open and/or the next attempt to start Tomcat fails because
the port is still in use.
In any case the Java process associated with Tomcat is still running.

The first issue of the message is really just a poorly worded diagnostic
message from Tomcat, apparently only in 5.5.12 (see also
http://marc.theaimsgroup.com/?l=tomcat-user&m=113307219707673&w=2) .

The second was a bug in the WorkerMontiorImpl.java not stopping the worker
thread correctly. 
Attached is the fix for that.
Note that rather using the deprecated Thread.stop() it closes the thread
programmatically.

patch 2 from Hajo Birthelmer

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
    portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java?view=diff&rev=501578&r1=501577&r2=501578
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/WorkerMonitorImpl.java Tue Jan 30 13:35:16 2007
@@ -92,7 +92,7 @@
     protected List workersMonitored = Collections.synchronizedList(new LinkedList());
 
     /** Renering Job Timeout monitor */
-    protected RenderingJobTimeoutMonitor jobMonitor;
+    protected RenderingJobTimeoutMonitor jobMonitor = null;
 
     public void start()
     {
@@ -104,7 +104,11 @@
     }
 
     public void stop()
-    {        
+    {    
+    	if (jobMonitor != null)
+    		jobMonitor.endThread();
+    	jobMonitor = null;
+    	
     }
     
     public void setQueue(Queue queue)
@@ -270,7 +274,8 @@
     class RenderingJobTimeoutMonitor extends Thread {
 
         long interval = 1000;
-
+        boolean shouldRun = true;
+        
         RenderingJobTimeoutMonitor(long interval) {
             super("RenderingJobTimeoutMonitor");
 
@@ -278,9 +283,20 @@
                 this.interval = interval;
             }
         }
-
+        /**
+         * Thread.stop() is deprecated.
+         * This method achieves the same by setting the run varaible "shouldRun" to false and interrupting the Thread, 
+         * effectively causing the thread to shutdown correctly.
+         *
+         */
+        public void endThread()
+        {
+        	shouldRun = false;
+        	this.interrupt();
+        }
+        
         public void run() {
-            while (true) {
+            while (shouldRun) {
                 try 
                 {
                     // Because a timeout worker can be removed 

Modified: portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java?view=diff&rev=501578&r1=501577&r2=501578
==============================================================================
--- portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java (original)
+++ portals/jetspeed-2/trunk/components/security/src/java/org/apache/jetspeed/security/SecurityHelper.java Tue Jan 30 13:35:16 2007
@@ -58,15 +58,19 @@
     public static Principal getPrincipal(Subject subject, Class classe)
     {
         Principal principal = null;
-        Iterator principals = subject.getPrincipals().iterator();
-        while (principals.hasNext())
-        {
-            Principal p = (Principal) principals.next();
-            if (classe.isInstance(p))
-            {
-                principal = p;
-                break;
-            }
+        Set principalList = subject.getPrincipals();
+        if (principalList != null)
+        { 
+        	Iterator principals = subject.getPrincipals().iterator();
+	        while (principals.hasNext())
+	        {
+	            Principal p = (Principal) principals.next();
+	            if (classe.isInstance(p))
+	            {
+	                principal = p;
+	                break;
+	            }
+	        }
         }
         return principal;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org