You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by el...@apache.org on 2008/09/15 00:01:17 UTC

svn commit: r695299 - /mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java

Author: elecharny
Date: Sun Sep 14 15:01:16 2008
New Revision: 695299

URL: http://svn.apache.org/viewvc?rev=695299&view=rev
Log:
o Added some javadoc
o used the correct exception in the catch

Modified:
    mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java?rev=695299&r1=695298&r2=695299&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/util/NamePreservingRunnable.java Sun Sep 14 15:01:16 2008
@@ -31,14 +31,28 @@
 public class NamePreservingRunnable implements Runnable {
     private final Logger logger = LoggerFactory.getLogger(NamePreservingRunnable.class);
 
+    /** The runnable name */
     private final String newName;
+    
+    /** The runnable task */
     private final Runnable runnable;
 
+    /**
+     * Creates a new instance of NamePreservingRunnable.
+     *
+     * @param runnable The underlying runnable
+     * @param newName The runnable's name
+     */
     public NamePreservingRunnable(Runnable runnable, String newName) {
         this.runnable = runnable;
         this.newName = newName;
     }
 
+    /**
+     * Run the runnable after having renamed the current thread's name 
+     * to the new name. When the runnable has completed, set back the 
+     * current thread name back to its origin. 
+     */
     public void run() {
         Thread currentThread = Thread.currentThread();
         String oldName = currentThread.getName();
@@ -61,10 +75,9 @@
     private void setName(Thread thread, String name) {
         try {
             thread.setName(name);
-        } catch (Exception e) {
-            // Probably SecurityException.
+        } catch (SecurityException se) {
             if (logger.isWarnEnabled()) {
-                logger.warn("Failed to set the thread name.", e);
+                logger.warn("Failed to set the thread name.", se);
             }
         }
     }