commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1694837 - in /commons/proper/daemon/trunk/src/main/java/org/apache/commons/daemon: DaemonPermission.java support/DaemonConfiguration.java support/DaemonLoader.java support/DaemonWrapper.java
Date Sat, 08 Aug 2015 18:41:30 GMT
Author: sebb
Date: Sat Aug  8 18:41:30 2015
New Revision: 1694837

URL: http://svn.apache.org/r1694837
Log:
Always use blocks for conditionals

Modified:
    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

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=1694837&r1=1694836&r2=1694837&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
Sat Aug  8 18:41:30 2015
@@ -190,8 +190,9 @@ public final class DaemonPermission exte
         super(target);
 
         // Check if the permission target name was specified
-        if (target == null)
+        if (target == null) {
             throw new IllegalArgumentException("Null permission name");
+        }
 
         // Check if this is a "control" permission and set up accordingly.
         if (CONTROL.equalsIgnoreCase(target)) {
@@ -266,16 +267,19 @@ public final class DaemonPermission exte
      */
     public boolean equals(Object object)
     {
-        if (object == this)
+        if (object == this) {
             return true;
+        }
 
-        if (!(object instanceof DaemonPermission))
+        if (!(object instanceof DaemonPermission)) {
             return false;
+        }
 
         DaemonPermission that = (DaemonPermission) object;
 
-        if (this.type != that.type)
+        if (this.type != that.type) {
             return false;
+        }
         return this.mask == that.mask;
     }
 
@@ -289,16 +293,19 @@ public final class DaemonPermission exte
      */
     public boolean implies(Permission permission)
     {
-        if (permission == this)
+        if (permission == this) {
             return true;
+        }
 
-        if (!(permission instanceof DaemonPermission))
+        if (!(permission instanceof DaemonPermission)) {
             return false;
+        }
 
         DaemonPermission that = (DaemonPermission) permission;
 
-        if (this.type != that.type)
+        if (this.type != that.type) {
             return false;
+        }
         return (this.mask & that.mask) == that.mask;
     }
 
@@ -323,8 +330,9 @@ public final class DaemonPermission exte
      */
     private void setupDescription()
     {
-        if (this.desc != null)
+        if (this.desc != null) {
             return;
+        }
 
         StringBuffer buf = new StringBuffer();
         buf.append(this.getClass().getName());
@@ -350,8 +358,9 @@ public final class DaemonPermission exte
     private int createControlMask(String actions)
         throws IllegalArgumentException
     {
-        if (actions == null)
+        if (actions == null) {
             return 0;
+        }
 
         int mask = 0;
         StringTokenizer tok = new StringTokenizer(actions, ",", false);
@@ -395,26 +404,32 @@ public final class DaemonPermission exte
         }
 
         if ((mask & MASK_CONTROL_STOP) == MASK_CONTROL_STOP) {
-            if (sep)
+            if (sep) {
                 buf.append(",");
-            else
+            }
+            else {
                 sep = true;
+            }
             buf.append(CONTROL_STOP);
         }
 
         if ((mask & MASK_CONTROL_SHUTDOWN) == MASK_CONTROL_SHUTDOWN) {
-            if (sep)
+            if (sep) {
                 buf.append(",");
-            else
+            }
+            else {
                 sep = true;
+            }
             buf.append(CONTROL_SHUTDOWN);
         }
 
         if ((mask & MASK_CONTROL_RELOAD) == MASK_CONTROL_RELOAD) {
-            if (sep)
+            if (sep) {
                 buf.append(",");
-            else
+            }
+            else {
                 sep = true;
+            }
             buf.append(CONTROL_RELOAD);
         }
 

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=1694837&r1=1694836&r2=1694837&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
Sat Aug  8 18:41:30 2015
@@ -85,8 +85,9 @@ public final class DaemonConfiguration
         boolean ok = false;
         FileInputStream file = null;
         try {
-            if (fileName == null)
+            if (fileName == null) {
                 fileName = DEFAULT_CONFIG;
+            }
             file = new FileInputStream(fileName);
             configurationProperties.clear();
             configurationProperties.load(file);
@@ -99,8 +100,9 @@ public final class DaemonConfiguration
             // Error reading properties file
         } finally {
             try {
-                if (file != null)
+                if (file != null) {
                     file.close();
+                }
             } catch (IOException ex) {
             }
         }
@@ -164,10 +166,10 @@ public final class DaemonConfiguration
     public String getProperty(String name)
         throws ParseException
     {
-        if (name == null)
+        if (name == null) {
             return null;
-        else
-            return expandProperty(configurationProperties.getProperty(PREFIX + name));
+        }
+        return expandProperty(configurationProperties.getProperty(PREFIX + name));
     }
 
     /**

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=1694837&r1=1694836&r2=1694837&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
Sat Aug  8 18:41:30 2015
@@ -65,8 +65,9 @@ public final class DaemonLoader
     {
         try {
             /* Check the class name */
-            if (cn == null)
+            if (cn == null) {
                 throw new NullPointerException("Null class name specified");
+            }
 
             /* Get the ClassLoader loading this class */
             ClassLoader cl = DaemonLoader.class.getClassLoader();
@@ -79,8 +80,9 @@ public final class DaemonLoader
             Class c = cl.loadClass(cn);
 
             /* This should _never_ happen, but doublechecking doesn't harm */
-            if (c == null)
+            if (c == null) {
                 throw new ClassNotFoundException(cn);
+            }
 
             /* Create a new instance of the daemon */
             c.newInstance();
@@ -122,12 +124,14 @@ public final class DaemonLoader
 
             /* Check if the underlying libray supplied a valid list of
                arguments */
-            if (args == null)
+            if (args == null) {
                 args = new String[0];
+            }
 
             /* Check the class name */
-            if (className == null)
+            if (className == null) {
                 throw new NullPointerException("Null class name specified");
+            }
 
             /* Get the ClassLoader loading this class */
             ClassLoader cl = DaemonLoader.class.getClassLoader();
@@ -147,11 +151,13 @@ public final class DaemonLoader
                 System.arraycopy(args, 0, a, 2, args.length);
                 args = a;
             }
-            else
+            else {
                 c = cl.loadClass(className);
+            }
             /* This should _never_ happen, but doublechecking doesn't harm */
-            if (c == null)
+            if (c == null) {
                 throw new ClassNotFoundException(className);
+            }
             /* Check interfaces */
             boolean isdaemon = false;
 
@@ -243,8 +249,9 @@ public final class DaemonLoader
             start.invoke(daemon, arg);
 
             /* Set the availability flag in the controller */
-            if (controller != null)
+            if (controller != null) {
                 controller.setAvailable(true);
+            }
 
         } catch (Throwable t) {
             /* In case we encounter ANY error, we dump the stack trace and
@@ -260,8 +267,9 @@ public final class DaemonLoader
     {
         try {
             /* Set the availability flag in the controller */
-            if (controller != null)
+            if (controller != null) {
                 controller.setAvailable(false);
+            }
 
             /* Attempt to stop the daemon */
             Object arg[] = null;
@@ -381,10 +389,12 @@ public final class DaemonLoader
                 this.setAvailable(false);
                 String msg = message;
                 if (exception != null) {
-                    if (msg != null)
+                    if (msg != null) {
                         msg = msg + ": " + exception.toString();
-                    else
+                    }
+                    else {
                         msg = exception.toString();
+                    }
                 }
                 DaemonLoader.failed(msg);
             }
@@ -422,4 +432,3 @@ public final class DaemonLoader
 
     }
 }
-

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=1694837&r1=1694836&r2=1694837&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
Sat Aug  8 18:41:30 2015
@@ -101,33 +101,39 @@ public class DaemonWrapper implements Da
                     break;
                 }
                 else if (args[i].equals("-daemon-properties")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     configFileName = args[i];
                 }
                 else if (args[i].equals("-start")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     startup.setClassName(args[i]);
                 }
                 else if (args[i].equals("-start-method")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     startup.setMethodName(args[i]);
                 }
                 else if (args[i].equals("-stop")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     shutdown.setClassName(args[i]);
                 }
                 else if (args[i].equals("-stop-method")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     shutdown.setMethodName(args[i]);
                 }
                 else if (args[i].equals("-stop-argument")) {
-                    if (++i == args.length)
+                    if (++i == args.length) {
                         throw new IllegalArgumentException(args[i - 1]);
+                    }
                     String[] aa = new String[1];
                     aa[0] = args[i];
                     shutdown.addArguments(aa);
@@ -198,20 +204,23 @@ public class DaemonWrapper implements Da
 
         protected void setClassName(String name)
         {
-            if (this.name == null)
+            if (this.name == null) {
                 this.name = name;
+            }
         }
         protected void setMethodName(String name)
         {
-            if (this.call == null)
+            if (this.call == null) {
                 this.call = name;
+            }
         }
         protected void addArguments(String[] args)
         {
             if (args != null) {
                 ArrayList aa = new ArrayList();
-                if (this.args != null)
+                if (this.args != null) {
                     aa.addAll(Arrays.asList(this.args));
+                }
                 aa.addAll(Arrays.asList(args));
                 this.args = (String[])aa.toArray(new String[aa.size()]);
             }
@@ -248,21 +257,25 @@ public class DaemonWrapper implements Da
                 call = "exit";
                 return;
             }
-            if (args == null)
+            if (args == null) {
                 args = new String[0];
-            if (call == null)
+            }
+            if (call == null) {
                 call = "main";
+            }
 
             // Get the ClassLoader loading this class
             ClassLoader cl = DaemonWrapper.class.getClassLoader();
-            if (cl == null)
+            if (cl == null) {
                 throw new NullPointerException("Cannot retrieve ClassLoader instance");
+            }
             Class[] ca = new Class[1];
             ca[0]      = args.getClass();
             // Find the required class
             main = cl.loadClass(name);
-            if (main == null)
+            if (main == null) {
                 throw new ClassNotFoundException(name);
+            }
             // Find the required method.
             // NoSuchMethodException will be thrown if matching method
             // is not found.



Mime
View raw message