commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r225179 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/text/VariableFormatter.java test/org/apache/commons/lang/text/VariableFormatterTest.java
Date Mon, 25 Jul 2005 20:52:12 GMT
Author: ggregory
Date: Mon Jul 25 13:52:08 2005
New Revision: 225179

URL: http://svn.apache.org/viewcvs?rev=225179&view=rev
Log:
IllegalStateException in text.VariableFormatter with "empty" keys.

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/VariableFormatter.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/VariableFormatterTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/VariableFormatter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/VariableFormatter.java?rev=225179&r1=225178&r2=225179&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/VariableFormatter.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/text/VariableFormatter.java
Mon Jul 25 13:52:08 2005
@@ -390,16 +390,16 @@
                     objResult = doReplace(objResult, priorVariables);
                     result.append(objResult);
                     objLen = objResult.toString().length();
-
-                    // pop the interpolated variable off the stack
-                    // this maintains priorVariables correctness for
-                    // properties with multiple interpolations, e.g.
-                    // prop.name=${some.other.prop1}/blahblah/${some.other.prop2}
-                    priorVariables.remove(priorVariables.size() - 1);
                 } else {
                     // variable not defined - so put it back in the value
                     result.append(getVariablePrefix()).append(variable).append(getVariableSuffix());
                 }
+
+                // pop the interpolated variable off the stack
+                // this maintains priorVariables correctness for
+                // properties with multiple interpolations, e.g.
+                // prop.name=${some.other.prop1}/blahblah/${some.other.prop2}
+                priorVariables.remove(priorVariables.size() - 1);
             }
 
             prec = end;

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/VariableFormatterTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/VariableFormatterTest.java?rev=225179&r1=225178&r2=225179&view=diff
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/VariableFormatterTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/text/VariableFormatterTest.java
Mon Jul 25 13:52:08 2005
@@ -226,6 +226,13 @@
         assertEquals("Variable ${var} is unknown!", this.getFormat().replace("Variable ${var}
is unknown!"));
     }
 
+    /**
+     * Tests a replace template with missing empty marker strings.
+     */
+    public void testReplaceEmptyKeys() {
+        testReplaceNoElement(REPLACE_TEMPLATE_EMPTY_KEYS);
+    }
+
     void testReplaceNoElement(String badReplaceTemplate) {
         assertEquals(badReplaceTemplate, this.getFormat().replaceObject(badReplaceTemplate));
         Map map = this.getValueMap();
@@ -243,13 +250,6 @@
     }
 
     /**
-     * Tests a replace template with missing prefix strings.
-     */
-    public void testReplaceNoPrefix() {
-        testReplaceNoElement(REPLACE_TEMPLATE_NO_PREFIX);
-    }
-
-    /**
      * Tests a replace template with missing marker strings.
      */
     public void testReplaceNoMarkers() {
@@ -257,15 +257,10 @@
     }
 
     /**
-     * Tests a replace template with missing empty marker strings.
+     * Tests a replace template with missing prefix strings.
      */
-    public void testReplaceEmptyKeys() {
-        try {
-            testReplaceNoElement(REPLACE_TEMPLATE_EMPTY_KEYS);
-            fail("Expected IllegalStateException.");
-        } catch (IllegalStateException e) {
-            // expected for now.
-        }
+    public void testReplaceNoPrefix() {
+        testReplaceNoElement(REPLACE_TEMPLATE_NO_PREFIX);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message