You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2015/08/08 20:24:26 UTC

svn commit: r1694834 - in /commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon: DaemonPermission.java support/DaemonConfiguration.java support/DaemonWrapper.java

Author: sebb
Date: Sat Aug  8 18:24:26 2015
New Revision: 1694834

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

Modified:
    commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/DaemonPermission.java
    commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
    commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java

Modified: commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/DaemonPermission.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/DaemonPermission.java?rev=1694834&r1=1694833&r2=1694834&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/DaemonPermission.java (original)
+++ commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/DaemonPermission.java Sat Aug  8 18:24:26 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/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java?rev=1694834&r1=1694833&r2=1694834&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java (original)
+++ commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonConfiguration.java Sat Aug  8 18:24:26 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) {
             }
         }
@@ -114,8 +116,9 @@ public final class DaemonConfiguration
         int btoken;
         int ctoken = 0;
 
-        if (propValue == null)
+        if (propValue == null) {
             return null;
+        }
         expanded = new StringBuffer();
         btoken   = propValue.indexOf(BTOKEN);
         while (btoken != -1) {
@@ -164,10 +167,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/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java
URL: http://svn.apache.org/viewvc/commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java?rev=1694834&r1=1694833&r2=1694834&view=diff
==============================================================================
--- commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java (original)
+++ commons/proper/daemon/branches/1.0.x/src/main/java/org/apache/commons/daemon/support/DaemonWrapper.java Sat Aug  8 18:24:26 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.