Skip to content

Commit

Permalink
Fixed incorrect variable substitution (https://issues.redhat.com/brow…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Aug 2, 2024
1 parent 2a5480e commit c3c57c1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/org/jgroups/conf/ProtocolConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public void substituteVariables() {
String replacement=Util.substituteVariable(val);
if(replacement != null)
properties.put(key, replacement);
else
it.remove();
}
}
properties_str=propertiesToString();
Expand Down
2 changes: 1 addition & 1 deletion src/org/jgroups/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -4997,7 +4997,7 @@ public static String substituteVariable(String input, Properties p) {
}
if(cache != null)
sb.append(cache);
return sb.toString();
return sb.length() == 0? null : sb.toString();
}

protected static char nextChar(String s, int index) {
Expand Down
4 changes: 4 additions & 0 deletions tests/junit-functional/org/jgroups/tests/UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,10 @@ public void testVariableSubstitution() {
val="hello ${name and end";
replacement=Util.substituteVariable(val);
assert val.equals(replacement);

val="${hello.world}";
replacement=Util.substituteVariable(val);
assert replacement == null;
}


Expand Down

0 comments on commit c3c57c1

Please sign in to comment.