incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1374422 - /sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
Date Fri, 17 Aug 2012 20:26:07 GMT
Author: justin
Date: Fri Aug 17 20:26:07 2012
New Revision: 1374422

URL: http://svn.apache.org/viewvc?rev=1374422&view=rev
Log:
SLING-2563 - auto generate label based on a stack trace

Modified:
    sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java

Modified: sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java?rev=1374422&r1=1374421&r2=1374422&view=diff
==============================================================================
--- sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
(original)
+++ sling/trunk/bundles/commons/threads/src/main/java/org/apache/sling/commons/threads/impl/DefaultThreadPoolManager.java
Fri Aug 17 20:26:07 2012
@@ -161,6 +161,19 @@ public class DefaultThreadPoolManager
         if ( config == null ) {
             throw new IllegalArgumentException("Config must not be null.");
         }
+
+        if ( label == null ) {
+            // generate the label by taking the first external frame off the stack trace
+            final StackTraceElement[] stackTrace = new Exception().getStackTrace();
+            if ( stackTrace != null && stackTrace.length > 1 ) {
+                if ( stackTrace[1].getClassName().equals( this.getClass().getName() ) ) {
+                    label = stackTrace[2].getClassName();
+                } else {
+                    label = stackTrace[1].getClassName();
+                }
+            }
+        }
+
         final String name = "ThreadPool-" + UUID.randomUUID().toString() +
              (label == null ? "" : " (" + label + ")");
         final Entry entry = new Entry(null, config, name);



Mime
View raw message