Commits

Michael Heemskerk committed da985a0

Minor change to reorder methods inside DefaultExternalProcessFactory

Comments (0)

Files changed (1)

src/main/java/com/atlassian/utils/process/DefaultExternalProcessFactory.java

         this.pool = executorService;
     }
 
+    private static ExecutorService createDefaultExecutorService() {
+        final String pooledThreadName = "ExtProcess IO Pump";
+
+        ThreadFactory threadFactory = new ThreadFactory() {
+            public Thread newThread(Runnable r) {
+                return new Thread(r, pooledThreadName);
+            }
+        };
+
+        return new ThreadPoolExecutor(6, Integer.MAX_VALUE, 2, TimeUnit.MINUTES,
+                new SynchronousQueue<Runnable>(), threadFactory) {
+
+            @Override
+            protected void beforeExecute(Thread thread, Runnable runnable) {
+                thread.setName(thread.getId() + ":" + ((LatchedRunnable) runnable).getName());
+                super.beforeExecute(thread, runnable);
+            }
+
+            @Override
+            protected void afterExecute(Runnable runnable, Throwable throwable) {
+                Thread.currentThread().setName(pooledThreadName);
+                super.afterExecute(runnable, throwable);
+            }
+        };
+    }
+
     public ExternalProcess create(ExternalProcessSettings settings) {
         if (shutdown) {
             throw new IllegalStateException("The DefaultExternalProcessFactory has been shutdown; new external processes cannot be created");
             process.setIdleTimeout(settings.getIdleTimeout());
         }
     }
-
-    private static ExecutorService createDefaultExecutorService() {
-        final String pooledThreadName = "ExtProcess IO Pump";
-
-        ThreadFactory threadFactory = new ThreadFactory() {
-            public Thread newThread(Runnable r) {
-                return new Thread(r, pooledThreadName);
-            }
-        };
-
-        return new ThreadPoolExecutor(6, Integer.MAX_VALUE, 2, TimeUnit.MINUTES,
-                new SynchronousQueue<Runnable>(), threadFactory) {
-
-            @Override
-            protected void beforeExecute(Thread thread, Runnable runnable) {
-                thread.setName(thread.getId() + ":" + ((LatchedRunnable) runnable).getName());
-                super.beforeExecute(thread, runnable);
-            }
-
-            @Override
-            protected void afterExecute(Runnable runnable, Throwable throwable) {
-                Thread.currentThread().setName(pooledThreadName);
-                super.afterExecute(runnable, throwable);
-            }
-        };
-    }
 }