[grizzly~git:740603da] [2.3.x] + fix the issue #1586

  • From: oleksiys@...
  • To: commits@...
  • Subject: [grizzly~git:740603da] [2.3.x] + fix the issue #1586
  • Date: Mon, 16 Sep 2013 22:35:34 +0000

Project:    grizzly
Repository: git
Revision:   740603da1ebf9ad5a753c58da4a83f497a0a9ed1
Author:     oleksiys
Date:       2013-09-16 22:35:06 UTC
Link:       

Log Message:
------------
[2.3.x] + fix the issue #1586
https://java.net/jira/browse/GRIZZLY-1586

"SyncThreadPool may stuck due to a racing issue"



Revisions:
----------
740603da1ebf9ad5a753c58da4a83f497a0a9ed1


Modified Paths:
---------------
modules/grizzly/src/main/java/org/glassfish/grizzly/threadpool/SyncThreadPool.java
modules/grizzly/src/main/java/org/glassfish/grizzly/utils/Exceptions.java


Diffs:
------
--- 
a/modules/grizzly/src/main/java/org/glassfish/grizzly/threadpool/SyncThreadPool.java
+++ 
b/modules/grizzly/src/main/java/org/glassfish/grizzly/threadpool/SyncThreadPool.java
@@ -127,9 +127,11 @@ public class SyncThreadPool extends AbstractThreadPool {
 
     @Override
     protected void startWorker(Worker worker) {
-        super.startWorker(worker);
-        activeThreadsCount++;
-        currentPoolSize++;
+        synchronized (stateLock) {
+            super.startWorker(worker);
+            activeThreadsCount++;
+            currentPoolSize++;
+        }
     }
 
     @Override--- 
a/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/Exceptions.java
+++ 
b/modules/grizzly/src/main/java/org/glassfish/grizzly/utils/Exceptions.java
@@ -43,6 +43,7 @@ package org.glassfish.grizzly.utils;
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.Map;
 
 /**
  * Exceptions utilities.
@@ -80,4 +81,26 @@ public class Exceptions {
 
         return new IOException(t);
     }
+    
+    /**
+     * @return {@link String} representation of all the JVM threads
+     * 
+     * @see Thread#getAllStackTraces()
+     */
+    public static String getAllStackTracesAsString() {
+        final StringBuilder sb = new StringBuilder(256);
+        
+        final Map<Thread, StackTraceElement[]> all = 
Thread.getAllStackTraces();
+        
+        for (Map.Entry<Thread, StackTraceElement[]> entry : all.entrySet()) {
+            sb.append(entry.getKey()).append('\n');
+            
+            for (StackTraceElement traceElement : entry.getValue()) {
+                sb.append("\tat ").append(traceElement).append('\n');        
        
+            }
+            
+        }
+        
+        return sb.toString();
+    }
 }





[grizzly~git:740603da] [2.3.x] + fix the issue #1586

oleksiys 09/16/2013
Terms of Use; Privacy Policy; Copyright ©2013-2015 (revision 20150226.965aeb8)
 
 
Close
loading
Please Confirm
Close