[grizzly~git:8f4557b9] [master] + fix the issue #1586

  • From: oleksiys@...
  • To: commits@...
  • Subject: [grizzly~git:8f4557b9] [master] + fix the issue #1586
  • Date: Mon, 16 Sep 2013 22:37:37 +0000

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

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

"SyncThreadPool may stuck due to a racing issue"

Conflicts:
        
modules/grizzly/src/main/java/org/glassfish/grizzly/utils/Exceptions.java



Revisions:
----------
8f4557b9098404b44e28a7c7703329bcee12f3ac


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
@@ -44,6 +44,7 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.Map;
 
 /**
  * Exceptions utilities.
@@ -93,4 +94,26 @@ public class Exceptions {
         pw.close();
         return stringWriter.toString();
     }
+    
+    /**
+     * @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:8f4557b9] [master] + fix the issue #1586

oleksiys 09/16/2013
Terms of Use; Privacy Policy; Copyright ©2013-2016 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close