Skip to content

Commit

Permalink
Change behavior for unresolved property
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed Jul 5, 2023
1 parent dd11fec commit a858609
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<properties>
<myArgLine>-javaagent:/path/to/some/jar.jar</myArgLine>
<liberty.jvm.argLine>@{myArgLine}</liberty.jvm.argLine>
<liberty.jvm.undefined>@{undefined}</liberty.jvm.undefined>
<liberty.jvm.minHeap>-Xms512m</liberty.jvm.minHeap>
<!-- This maxHeap property should NOT override the one specified below in jvmOptions -->
<liberty.jvm.maxHeap>-Xmx1024m</liberty.jvm.maxHeap>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,37 @@ public void testJvmOptionsFileElements() throws Exception {
String fileContents = FileUtils.fileRead(TARGET_JVM_OPTIONS).replaceAll("\r","");

String[] fileContentsArray = fileContents.split("\\n");
assertTrue("fileContents", fileContentsArray.length == 5);
assertTrue("fileContents", fileContentsArray.length == 6);

boolean myArgLineKeyFound = false;
boolean myArgLineValueFound = false;
boolean myXms512mFound = false;
boolean myXmx1024mFound = false;
boolean myUndefinedVarFound = false;

for (int i=0; i < fileContentsArray.length; i++) {
String nextLine = fileContentsArray[i];
// verify that -Xmx768m is last in the jvm.options file, and that -Xms512m and -Xmx1024m appear before it.
if (i == 0) {
assertTrue("comment not found on first line", nextLine.equals("# Generated by liberty-maven-plugin"));
} else if (i == 4) {
} else if (i == 5) {
assertTrue("-Xmx768m not found on last line", nextLine.equals("-Xmx768m"));
} else {
if (nextLine.equals("@{myArgLine}")) {
myArgLineKeyFound = true;
} else if (nextLine.equals("-Xms512m")) {
if (nextLine.equals("-Xms512m")) {
myXms512mFound = true;
} else if (nextLine.equals("-Xmx1024m")) {
myXmx1024mFound = true;
} else if (nextLine.equals("-javaagent:/path/to/some/jar.jar")) {
myArgLineValueFound = true;
} else if (nextLine.equals("@{undefined}")) {
myUndefinedVarFound = true;
}
}
}

assertFalse("@{myArgLine} found", myArgLineKeyFound);
assertTrue("-javaagent:/path/to/some/jar.jar not found", myArgLineValueFound);
assertTrue("-Xms512m not found", myXms512mFound);
assertTrue("-Xmx1024m not found", myXmx1024mFound);
assertTrue("-javaagent:/path/to/some/jar.jar not found", myArgLineValueFound);
assertTrue("@{undefined} not found", myUndefinedVarFound);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,11 @@ private String handleLatePropertyResolution(String value) {
while (m.find()) {
String varName = m.group(1);
if (project.getProperties().containsKey(varName)) {
String replacementValue = project.getProperties().getProperty(varName,"");
returnValue = returnValue.replace("@{"+varName+"}", replacementValue);
getLog().debug("Replaced Liberty configuration property value @{"+varName+"} with value "+replacementValue);
String replacementValue = project.getProperties().getProperty(varName);
if (replacementValue != null) {
returnValue = returnValue.replace("@{"+varName+"}", replacementValue);
getLog().debug("Replaced Liberty configuration property value @{"+varName+"} with value "+replacementValue);
}
}
}

Expand Down

0 comments on commit a858609

Please sign in to comment.