You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2013/08/22 17:41:27 UTC

svn commit: r1516490 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java

Author: ggregory
Date: Thu Aug 22 15:41:27 2013
New Revision: 1516490

URL: http://svn.apache.org/r1516490
Log:
Make reading this nested code easier: Statements unnecessarily nested within else clause.

Modified:
    logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java

Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java?rev=1516490&r1=1516489&r2=1516490&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/helpers/OptionConverter.java Thu Aug 22 15:41:27 2013
@@ -292,39 +292,37 @@ public final class OptionConverter {
                 // no more variables
                 if (i == 0) { // this is a simple string
                     return val;
-                } else { // add the tail string which contails no variables and return the result.
-                    sbuf.append(val.substring(i, val.length()));
-                    return sbuf.toString();
                 }
-            } else {
-                sbuf.append(val.substring(i, j));
-                k = val.indexOf(DELIM_STOP, j);
-                if (k == -1) {
-                    throw new IllegalArgumentException('"' + val +
-                        "\" has no closing brace. Opening brace at position " + j
-                        + '.');
-                } else {
-                    j += DELIM_START_LEN;
-                    final String key = val.substring(j, k);
-                    // first try in System properties
-                    String replacement = PropertiesUtil.getProperties().getStringProperty(key, null);
-                    // then try props parameter
-                    if (replacement == null && props != null) {
-                        replacement = props.getProperty(key);
-                    }
+                // add the tail string which contails no variables and return the result.
+                sbuf.append(val.substring(i, val.length()));
+                return sbuf.toString();
+            }
+            sbuf.append(val.substring(i, j));
+            k = val.indexOf(DELIM_STOP, j);
+            if (k == -1) {
+                throw new IllegalArgumentException('"' + val +
+                    "\" has no closing brace. Opening brace at position " + j
+                    + '.');
+            }
+            j += DELIM_START_LEN;
+            final String key = val.substring(j, k);
+            // first try in System properties
+            String replacement = PropertiesUtil.getProperties().getStringProperty(key, null);
+            // then try props parameter
+            if (replacement == null && props != null) {
+                replacement = props.getProperty(key);
+            }
 
-                    if (replacement != null) {
-                        // Do variable substitution on the replacement string
-                        // such that we can solve "Hello ${x2}" as "Hello p1"
-                        // the where the properties are
-                        // x1=p1
-                        // x2=${x1}
-                        final String recursiveReplacement = substVars(replacement, props);
-                        sbuf.append(recursiveReplacement);
-                    }
-                    i = k + DELIM_STOP_LEN;
-                }
+            if (replacement != null) {
+                // Do variable substitution on the replacement string
+                // such that we can solve "Hello ${x2}" as "Hello p1"
+                // the where the properties are
+                // x1=p1
+                // x2=${x1}
+                final String recursiveReplacement = substVars(replacement, props);
+                sbuf.append(recursiveReplacement);
             }
+            i = k + DELIM_STOP_LEN;
         }
     }
 }