FELIX-1481: When performing variable substitution, fileinstall throws an exception if there is a start or stop delimiter without the other one
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@804096 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/fileinstall/src/main/java/org/apache/felix/fileinstall/util/Util.java b/fileinstall/src/main/java/org/apache/felix/fileinstall/util/Util.java
index f5c51ed..a81f376 100644
--- a/fileinstall/src/main/java/org/apache/felix/fileinstall/util/Util.java
+++ b/fileinstall/src/main/java/org/apache/felix/fileinstall/util/Util.java
@@ -88,16 +88,10 @@
// If we do not have a start or stop delimiter, then just
// return the existing value.
- if ((startDelim < 0) && (stopDelim < 0))
+ if ((startDelim < 0) || (stopDelim < 0))
{
return val;
}
- // At this point, we found a stop delimiter without a start,
- // so throw an exception.
- else if (((startDelim < 0) || (startDelim > stopDelim)) && (stopDelim >= 0))
- {
- throw new IllegalArgumentException("stop delimiter with no start delimiter: " + val);
- }
// At this point, we have found a variable placeholder so
// we must perform a variable substitution on it.
diff --git a/fileinstall/src/test/java/org/apache/felix/fileinstall/util/UtilTest.java b/fileinstall/src/test/java/org/apache/felix/fileinstall/util/UtilTest.java
index 4e55071..ca68a37 100644
--- a/fileinstall/src/test/java/org/apache/felix/fileinstall/util/UtilTest.java
+++ b/fileinstall/src/test/java/org/apache/felix/fileinstall/util/UtilTest.java
@@ -47,6 +47,12 @@
}
+ public void testSubstitutionFailures()
+ {
+ assertEquals("a}", Util.substVars("a}", "b", null, new Hashtable()));
+ assertEquals("${a", Util.substVars("${a", "b", null, new Hashtable()));
+ }
+
public void testCanRecognizeInvalidJar()
{
assertFalse(Util.isValidJar("src/test/resources/watched/firstjar.jar"));