commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1802193 - in /commons/proper/daemon/trunk/src: main/java/org/apache/commons/daemon/ main/java/org/apache/commons/daemon/support/ test/java/org/apache/commons/daemon/
Date Mon, 17 Jul 2017 19:25:26 GMT
Author: ggregory
Date: Mon Jul 17 19:25:26 2017
New Revision: 1802193

URL: http://svn.apache.org/viewvc?rev=1802193&view=rev
Log:
Use final.

Modified:
    commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonInitException.java
    commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonPermission.java
    commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
    commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonLoader.java
    commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
    commons/proper/daemon/trunk/src/test/java/org/apache/commons/daemon/SimpleDaemon.java

Modified: commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonInitException.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonInitException.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonInitException.java
(original)
+++ commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonInitException.java
Mon Jul 17 19:25:26 2017
@@ -28,18 +28,18 @@ public class DaemonInitException extends
     // don't rely on Throwable#getCause (jdk1.4)
     private final Throwable cause;
 
-    public DaemonInitException(String message) {
+    public DaemonInitException(final String message) {
         super(message);
         this.cause = null;
     }
 
-    public DaemonInitException(String message, Throwable cause) {
+    public DaemonInitException(final String message, final Throwable cause) {
         super(message);
         this.cause = cause;
     }
 
     public String getMessageWithCause() {
-        String extra = this.cause == null ? "" : ": " + this.cause.getMessage();
+        final String extra = this.cause == null ? "" : ": " + this.cause.getMessage();
         return getMessage() + extra;
     }
 

Modified: commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonPermission.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonPermission.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonPermission.java
(original)
+++ commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/DaemonPermission.java
Mon Jul 17 19:25:26 2017
@@ -183,7 +183,7 @@ public final class DaemonPermission exte
      * @throws IllegalArgumentException If the specified target name is not
      *                supported.
      */
-    public DaemonPermission(String target)
+    public DaemonPermission(final String target)
         throws IllegalArgumentException
     {
         // Setup the target name of this permission object.
@@ -217,7 +217,7 @@ public final class DaemonPermission exte
      *                supported, or the specified list of actions includes an
      *                invalid value.
      */
-    public DaemonPermission(String target, String actions)
+    public DaemonPermission(final String target, final String actions)
         throws IllegalArgumentException
     {
         // Setup this instance's target name.
@@ -268,7 +268,7 @@ public final class DaemonPermission exte
      *         this <code>DaemonPermission</code> instance or not.
      */
     @Override
-    public boolean equals(Object object)
+    public boolean equals(final Object object)
     {
         if (object == this) {
             return true;
@@ -278,7 +278,7 @@ public final class DaemonPermission exte
             return false;
         }
 
-        DaemonPermission that = (DaemonPermission) object;
+        final DaemonPermission that = (DaemonPermission) object;
 
         if (this.type != that.type) {
             return false;
@@ -295,7 +295,7 @@ public final class DaemonPermission exte
      *         not.
      */
     @Override
-    public boolean implies(Permission permission)
+    public boolean implies(final Permission permission)
     {
         if (permission == this) {
             return true;
@@ -305,7 +305,7 @@ public final class DaemonPermission exte
             return false;
         }
 
-        DaemonPermission that = (DaemonPermission) permission;
+        final DaemonPermission that = (DaemonPermission) permission;
 
         if (this.type != that.type) {
             return false;
@@ -339,7 +339,7 @@ public final class DaemonPermission exte
             return;
         }
 
-        StringBuffer buf = new StringBuffer();
+        final StringBuffer buf = new StringBuffer();
         buf.append(this.getClass().getName());
         buf.append('[');
         switch (this.type) {
@@ -360,7 +360,7 @@ public final class DaemonPermission exte
     /**
      * Creates a permission mask for a given control actions string.
      */
-    private int createControlMask(String actions)
+    private int createControlMask(final String actions)
         throws IllegalArgumentException
     {
         if (actions == null) {
@@ -368,10 +368,10 @@ public final class DaemonPermission exte
         }
 
         int mask = 0;
-        StringTokenizer tok = new StringTokenizer(actions, ",", false);
+        final StringTokenizer tok = new StringTokenizer(actions, ",", false);
 
         while (tok.hasMoreTokens()) {
-            String val = tok.nextToken().trim();
+            final String val = tok.nextToken().trim();
 
             if (WILDCARD.equals(val)) {
                 return MASK_CONTROL_START | MASK_CONTROL_STOP |
@@ -398,9 +398,9 @@ public final class DaemonPermission exte
     }
 
     /** Creates a actions list for a given control permission mask. */
-    private String createControlActions(int mask)
+    private String createControlActions(final int mask)
     {
-        StringBuffer buf = new StringBuffer();
+        final StringBuffer buf = new StringBuffer();
         boolean sep = false;
 
         if ((mask & MASK_CONTROL_START) == MASK_CONTROL_START) {

Modified: commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
(original)
+++ commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
Mon Jul 17 19:25:26 2017
@@ -91,23 +91,23 @@ public final class DaemonConfiguration
             configurationProperties.load(file);
             ok = true;
         }
-        catch (FileNotFoundException ex) {
+        catch (final FileNotFoundException ex) {
             // fileName does not exist
         }
-        catch (IOException ex) {
+        catch (final IOException ex) {
             // Error reading properties file
         } finally {
             try {
                 if (file != null) {
                     file.close();
                 }
-            } catch (IOException ex) {
+            } catch (final IOException ex) {
             }
         }
         return ok;
     }
 
-    private String expandProperty(String propValue)
+    private String expandProperty(final String propValue)
         throws ParseException
     {
         StringBuffer expanded;
@@ -127,9 +127,9 @@ public final class DaemonConfiguration
                 btoken = propValue.indexOf(BTOKEN, btoken + BTOKEN.length());
                 continue;
             }
-            int etoken = propValue.indexOf(ETOKEN, btoken);
+            final int etoken = propValue.indexOf(ETOKEN, btoken);
             if (etoken != -1) {
-                String variable = propValue.substring(btoken + BTOKEN.length(), etoken);
+                final String variable = propValue.substring(btoken + BTOKEN.length(), etoken);
                 String sysvalue = systemProperties.getProperty(variable);
                 if (sysvalue == null) {
                     // Try with the environment if there was no
@@ -137,7 +137,7 @@ public final class DaemonConfiguration
                     sysvalue = System.getenv(variable); // N.B. Deprecated in Java 1.3/1.4,
but re-instated in Java 1.5+
                 }
                 if (sysvalue != null) {
-                    String strtoken = propValue.substring(ctoken, btoken);
+                    final String strtoken = propValue.substring(ctoken, btoken);
                     expanded.append(strtoken);
                     expanded.append(sysvalue);
                     ctoken = etoken + ETOKEN.length();
@@ -162,7 +162,7 @@ public final class DaemonConfiguration
      *
      * @throws ParseException if the property is wrongly formatted.
      */
-    public String getProperty(String name)
+    public String getProperty(final String name)
         throws ParseException
     {
         if (name == null) {
@@ -186,10 +186,10 @@ public final class DaemonConfiguration
      *
      * @throws ParseException if the property is wrongly formatted.
      */
-    public String[] getPropertyArray(String name)
+    public String[] getPropertyArray(final String name)
         throws ParseException
     {
-        ArrayList<String> list = new ArrayList<String>();
+        final ArrayList<String> list = new ArrayList<String>();
         String    args;
 
         // Load daemon.arg[0] ... daemon.arg[n] into the String array.

Modified: commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonLoader.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonLoader.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonLoader.java
(original)
+++ commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonLoader.java
Mon Jul 17 19:25:26 2017
@@ -59,7 +59,7 @@ public final class DaemonLoader
                            System.getProperty("commons.daemon.process.parent") + ")");
     }
 
-    public static boolean check(String cn)
+    public static boolean check(final String cn)
     {
         try {
             /* Check the class name */
@@ -68,14 +68,14 @@ public final class DaemonLoader
             }
 
             /* Get the ClassLoader loading this class */
-            ClassLoader cl = DaemonLoader.class.getClassLoader();
+            final ClassLoader cl = DaemonLoader.class.getClassLoader();
             if (cl == null) {
                 System.err.println("Cannot retrieve ClassLoader instance");
                 return false;
             }
 
             /* Find the required class */
-            Class<?> c = cl.loadClass(cn);
+            final Class<?> c = cl.loadClass(cn);
 
             /* This should _never_ happen, but doublechecking doesn't harm */
             if (c == null) {
@@ -85,7 +85,7 @@ public final class DaemonLoader
             /* Create a new instance of the daemon */
             c.newInstance();
 
-        } catch (Throwable t) {
+        } catch (final Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
              * return false (load, start and stop won't be called).
              */
@@ -105,14 +105,14 @@ public final class DaemonLoader
                 return true;
             }
             System.out.println("Daemon doesn't support signaling");
-        } catch (Throwable ex) {
+        } catch (final Throwable ex) {
             System.err.println("Cannot send signal: " + ex);
             ex.printStackTrace(System.err);
         }
         return false;
     }
 
-    public static boolean load(String className, String args[])
+    public static boolean load(final String className, String args[])
     {
         try {
             /* Check if the underlying library supplied a valid list of
@@ -127,7 +127,7 @@ public final class DaemonLoader
             }
 
             /* Get the ClassLoader loading this class */
-            ClassLoader cl = DaemonLoader.class.getClassLoader();
+            final ClassLoader cl = DaemonLoader.class.getClassLoader();
             if (cl == null) {
                 System.err.println("Cannot retrieve ClassLoader instance");
                 return false;
@@ -138,7 +138,7 @@ public final class DaemonLoader
                  * and modify arguments to include the real class name.
                  */
                 c = DaemonWrapper.class;
-                String[] a = new String[args.length + 2];
+                final String[] a = new String[args.length + 2];
                 a[0] = "-start";
                 a[1] = className.substring(1);
                 System.arraycopy(args, 0, a, 2, args.length);
@@ -155,10 +155,10 @@ public final class DaemonLoader
             boolean isdaemon = false;
 
             try {
-                Class<?> dclass = cl.loadClass("org.apache.commons.daemon.Daemon");
+                final Class<?> dclass = cl.loadClass("org.apache.commons.daemon.Daemon");
                 isdaemon = dclass.isAssignableFrom(c);
             }
-            catch (Exception cnfex) {
+            catch (final Exception cnfex) {
                 // Swallow if Daemon not found.
             }
 
@@ -180,7 +180,7 @@ public final class DaemonLoader
 
             try {
                 signal = c.getMethod("signal", myclass);
-            } catch (NoSuchMethodException e) {
+            } catch (final NoSuchMethodException e) {
                 // Signalling will be disabled.
             }
 
@@ -195,24 +195,24 @@ public final class DaemonLoader
                 controller.setAvailable(false);
 
                 /* Create context */
-                Context context = new Context();
+                final Context context = new Context();
                 context.setArguments(args);
                 context.setController(controller);
 
                 /* Now we want to call the init method in the class */
-                Object arg[] = new Object[1];
+                final Object arg[] = new Object[1];
                 arg[0] = context;
                 init.invoke(daemon, arg);
             }
             else {
-                Object arg[] = new Object[1];
+                final Object arg[] = new Object[1];
                 arg[0] = args;
                 init.invoke(daemon, arg);
             }
 
         }
-        catch (InvocationTargetException e) {
-            Throwable thrown = e.getTargetException();
+        catch (final InvocationTargetException e) {
+            final Throwable thrown = e.getTargetException();
             /* DaemonInitExceptions can fail with a nicer message */
             if (thrown instanceof DaemonInitException) {
                 failed(((DaemonInitException) thrown).getMessageWithCause());
@@ -222,7 +222,7 @@ public final class DaemonLoader
             }
             return false;
         }
-        catch (Throwable t) {
+        catch (final Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
              * return false (load, start and stop won't be called).
              */
@@ -237,7 +237,7 @@ public final class DaemonLoader
     {
         try {
             /* Attempt to start the daemon */
-            Object arg[] = null;
+            final Object arg[] = null;
             start.invoke(daemon, arg);
 
             /* Set the availability flag in the controller */
@@ -245,7 +245,7 @@ public final class DaemonLoader
                 controller.setAvailable(true);
             }
 
-        } catch (Throwable t) {
+        } catch (final Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
              * return false (load, start and stop won't be called).
              */
@@ -264,10 +264,10 @@ public final class DaemonLoader
             }
 
             /* Attempt to stop the daemon */
-            Object arg[] = null;
+            final Object arg[] = null;
             stop.invoke(daemon, arg);
         }
-        catch (Throwable t) {
+        catch (final Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
              * return false (load, start and stop won't be called).
              */
@@ -281,12 +281,12 @@ public final class DaemonLoader
     {
         try {
             /* Attempt to stop the daemon */
-            Object arg[] = null;
+            final Object arg[] = null;
             destroy.invoke(daemon, arg);
 
             daemon = null;
             controller = null;
-        } catch (Throwable t) {
+        } catch (final Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
              * return false (load, start and stop won't be called).
              */
@@ -318,7 +318,7 @@ public final class DaemonLoader
             }
         }
 
-        private void setAvailable(boolean available)
+        private void setAvailable(final boolean available)
         {
             synchronized (this) {
                 this.available = available;
@@ -358,19 +358,19 @@ public final class DaemonLoader
         }
 
         @Override
-        public void fail(String message)
+        public void fail(final String message)
         {
             fail(message, null);
         }
 
         @Override
-        public void fail(Exception exception)
+        public void fail(final Exception exception)
         {
             fail(null, exception);
         }
 
         @Override
-        public void fail(String message, Exception exception)
+        public void fail(final String message, final Exception exception)
         {
             synchronized (this) {
                 this.setAvailable(false);
@@ -403,7 +403,7 @@ public final class DaemonLoader
             return daemonController;
         }
 
-        public void setController(DaemonController controller)
+        public void setController(final DaemonController controller)
         {
             this.daemonController = controller;
         }
@@ -414,7 +414,7 @@ public final class DaemonLoader
             return args;
         }
 
-        public void setArguments(String[]args)
+        public void setArguments(final String[]args)
         {
             this.args = args;
         }

Modified: commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
(original)
+++ commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
Mon Jul 17 19:25:26 2017
@@ -82,10 +82,10 @@ public class DaemonWrapper implements Da
      * appended to any existing values.</b>
      */
     @Override
-    public void init(DaemonContext context)
+    public void init(final DaemonContext context)
         throws Exception
     {
-        String[] args = context.getArguments();
+        final String[] args = context.getArguments();
 
         if (args != null) {
             int i;
@@ -131,7 +131,7 @@ public class DaemonWrapper implements Da
                     if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
                     }
-                    String[] aa = new String[1];
+                    final String[] aa = new String[1];
                     aa[0] = args[i];
                     shutdown.addArguments(aa);
                 }
@@ -142,7 +142,7 @@ public class DaemonWrapper implements Da
                 }
             }
             if (args.length > i) {
-                String[] copy = new String[args.length - i];
+                final String[] copy = new String[args.length - i];
                 System.arraycopy(args, i, copy, 0, copy.length);
                 startup.addArguments(copy);
             }
@@ -202,22 +202,22 @@ public class DaemonWrapper implements Da
         {
         }
 
-        protected void setClassName(String name)
+        protected void setClassName(final String name)
         {
             if (this.name == null) {
                 this.name = name;
             }
         }
-        protected void setMethodName(String name)
+        protected void setMethodName(final String name)
         {
             if (this.call == null) {
                 this.call = name;
             }
         }
-        protected void addArguments(String[] args)
+        protected void addArguments(final String[] args)
         {
             if (args != null) {
-                ArrayList<String> aa = new ArrayList<String>();
+                final ArrayList<String> aa = new ArrayList<String>();
                 if (this.args != null) {
                     aa.addAll(Arrays.asList(this.args));
                 }
@@ -241,7 +241,7 @@ public class DaemonWrapper implements Da
                     // We only need object instance for non-static methods.
                     obj = main.newInstance();
                 }
-                Object arg[] = new Object[1];
+                final Object arg[] = new Object[1];
 
                 arg[0] = args;
                 inst.invoke(obj, arg);
@@ -265,11 +265,11 @@ public class DaemonWrapper implements Da
             }
 
             // Get the ClassLoader loading this class
-            ClassLoader cl = DaemonWrapper.class.getClassLoader();
+            final ClassLoader cl = DaemonWrapper.class.getClassLoader();
             if (cl == null) {
                 throw new NullPointerException("Cannot retrieve ClassLoader instance");
             }
-            Class<?>[] ca = new Class[1];
+            final Class<?>[] ca = new Class[1];
             ca[0]      = args.getClass();
             // Find the required class
             main = cl.loadClass(name);

Modified: commons/proper/daemon/trunk/src/test/java/org/apache/commons/daemon/SimpleDaemon.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/test/java/org/apache/commons/daemon/SimpleDaemon.java?rev=1802193&r1=1802192&r2=1802193&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/test/java/org/apache/commons/daemon/SimpleDaemon.java
(original)
+++ commons/proper/daemon/trunk/src/test/java/org/apache/commons/daemon/SimpleDaemon.java
Mon Jul 17 19:25:26 2017
@@ -56,14 +56,14 @@ public class SimpleDaemon implements Dae
      * init and destroy were added in jakarta-tomcat-daemon.
      */
     @Override
-    public void init(DaemonContext context)
+    public void init(final DaemonContext context)
     throws Exception {
         System.err.println("SimpleDaemon: instance "+this.hashCode()+
                            " init");
 
         int port=1200;
 
-        String[] a = context.getArguments();
+        final String[] a = context.getArguments();
 
         if (a.length>0) port=Integer.parseInt(a[0]);
         if (a.length>1) this.directory=a[1];
@@ -116,24 +116,24 @@ public class SimpleDaemon implements Dae
         try {
             while(!this.stopping) {
                 checkForReload();
-                Socket socket=this.server.accept();
+                final Socket socket=this.server.accept();
                 checkForReload();
 
-                Handler handler=new Handler(socket,this,this.controller);
+                final Handler handler=new Handler(socket,this,this.controller);
                 handler.setConnectionNumber(number++);
                 handler.setDirectoryName(this.directory);
                 new Thread(handler).start();
             }
-        } catch (IOException e) {
+        } catch (final IOException e) {
             /* Don't dump any error message if we are stopping. A IOException
                is generated when the ServerSocket is closed in stop() */
             if (!this.stopping) e.printStackTrace(System.err);
         }
 
         /* Terminate all handlers that at this point are still open */
-        Enumeration<Handler> openhandlers=this.handlers.elements();
+        final Enumeration<Handler> openhandlers=this.handlers.elements();
         while (openhandlers.hasMoreElements()) {
-            Handler handler=openhandlers.nextElement();
+            final Handler handler=openhandlers.nextElement();
             System.err.println("SimpleDaemon: dropping connection "+
                                handler.getConnectionNumber());
             handler.close();
@@ -159,13 +159,13 @@ public class SimpleDaemon implements Dae
       }
     }
 
-    protected void addHandler(Handler handler) {
+    protected void addHandler(final Handler handler) {
         synchronized (handler) {
             this.handlers.add(handler);
         }
     }
 
-    protected void removeHandler(Handler handler) {
+    protected void removeHandler(final Handler handler) {
         synchronized (handler) {
             this.handlers.remove(handler);
         }
@@ -179,7 +179,7 @@ public class SimpleDaemon implements Dae
         private Socket socket=null;
         private int number=0;
 
-        public Handler(Socket s, SimpleDaemon p, DaemonController c) {
+        public Handler(final Socket s, final SimpleDaemon p, final DaemonController c) {
             super();
             this.socket=s;
             this.parent=p;
@@ -192,11 +192,11 @@ public class SimpleDaemon implements Dae
             System.err.println("SimpleDaemon: connection "+this.number+
                                " opened from "+this.socket.getInetAddress());
             try {
-                InputStream in=this.socket.getInputStream();
-                OutputStream out=this.socket.getOutputStream();
+                final InputStream in=this.socket.getInputStream();
+                final OutputStream out=this.socket.getOutputStream();
                 handle(in,out);
                 this.socket.close();
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 e.printStackTrace(System.err);
             }
             System.err.println("SimpleDaemon: connection "+this.number+
@@ -207,12 +207,12 @@ public class SimpleDaemon implements Dae
         public void close() {
             try {
                 this.socket.close();
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 e.printStackTrace(System.err);
             }
         }
 
-        public void setConnectionNumber(int number) {
+        public void setConnectionNumber(final int number) {
             this.number=number;
         }
 
@@ -220,7 +220,7 @@ public class SimpleDaemon implements Dae
             return(this.number);
         }
 
-        public void setDirectoryName(String directory) {
+        public void setDirectoryName(final String directory) {
             this.directory=directory;
         }
 
@@ -228,19 +228,19 @@ public class SimpleDaemon implements Dae
             return(this.directory);
         }
 
-        public void log(String name)
+        public void log(final String name)
         throws IOException {
-            OutputStream file=new FileOutputStream(name,true);
-            PrintStream out=new PrintStream(file);
-            SimpleDateFormat fmt=new SimpleDateFormat();
+            final OutputStream file=new FileOutputStream(name,true);
+            final PrintStream out=new PrintStream(file);
+            final SimpleDateFormat fmt=new SimpleDateFormat();
 
             out.println(fmt.format(new Date()));
             out.close();
             file.close();
         }
 
-        public void handle(InputStream in, OutputStream os) {
-            PrintStream out=new PrintStream(os);
+        public void handle(final InputStream in, final OutputStream os) {
+            final PrintStream out=new PrintStream(os);
 
             while(true) {
                 try {
@@ -258,7 +258,7 @@ public class SimpleDaemon implements Dae
                     }
 
                     /* Read an option from the client */
-                    int x=in.read();
+                    final int x=in.read();
 
                     switch (x) {
                         /* If the socket was closed, we simply return */
@@ -270,7 +270,7 @@ public class SimpleDaemon implements Dae
                             out.println("Attempting a shutdown...");
                             try {
                                 this.controller.shutdown();
-                            } catch (IllegalStateException e) {
+                            } catch (final IllegalStateException e) {
                                 out.println();
                                 out.println("Can't shutdown now");
                                 e.printStackTrace(out);
@@ -282,7 +282,7 @@ public class SimpleDaemon implements Dae
                             out.println("Attempting a reload...");
                             try {
                                 this.controller.reload();
-                            } catch (IllegalStateException e) {
+                            } catch (final IllegalStateException e) {
                                 out.println();
                                 out.println("Can't reload now");
                                 e.printStackTrace(out);
@@ -291,14 +291,14 @@ public class SimpleDaemon implements Dae
 
                         /* Disconnect */
                         case '3':
-                            String name=this.getDirectoryName()+
+                            final String name=this.getDirectoryName()+
                                         "/SimpleDaemon."+
                                         this.getConnectionNumber()+
                                         ".tmp";
                             try {
                                 this.log(name);
                                 out.println("File '"+name+"' created");
-                            } catch (IOException e) {
+                            } catch (final IOException e) {
                                 e.printStackTrace(out);
                             }
                             break;
@@ -325,7 +325,7 @@ public class SimpleDaemon implements Dae
                     }
 
                 /* If we get an IOException we return (disconnect) */
-                } catch (IOException e) {
+                } catch (final IOException e) {
                     System.err.println("SimpleDaemon: IOException in "+
                                        "connection "+
                                        this.getConnectionNumber());



Mime
View raw message