Skip to content

Commit

Permalink
small shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
dshimo committed Mar 7, 2024
1 parent 0719306 commit f97ef17
Showing 1 changed file with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,36 @@ public static String resolveVariables(CommonLoggerI log, String nodeValue, Colle
// Found recursive reference when resolving variables. Log message and return null.
log.debug("Found a recursive variable reference when resolving ${" + varName + "}");
return null;
} else {
variablesToResolve.add(varName);
}
variablesToResolve.add(varName);
}

for (String nextVariable : variablesToResolve) {
String value = getPropertyValue(nextVariable, props, defaultProps, libDirPropFiles);

if (value != null && !value.isEmpty()) {
Collection<String> thisVariableChain = new HashSet<String> ();
thisVariableChain.add(nextVariable);
if (value == null || value.isEmpty()) {
// Variable could not be resolved. Log message and return null.
log.debug("Variable " + nextVariable + " cannot be resolved.");
return null;
}

if (variableChain != null && !variableChain.isEmpty()) {
thisVariableChain.addAll(variableChain);
}
Collection<String> thisVariableChain = new HashSet<String> ();
thisVariableChain.add(nextVariable);

String resolvedValue = resolveVariables(log, value, thisVariableChain, props, defaultProps, libDirPropFiles);

if (resolvedValue != null) {
String escapedVariable = Matcher.quoteReplacement(nextVariable);
// For Windows, avoid escaping the backslashes in the resolvedValue by changing to forward slashes
resolvedValue = resolvedValue.replace("\\","/");
resolved = resolved.replaceAll("\\$\\{" + escapedVariable + "\\}", resolvedValue);
} else {
// Variable value could not be resolved. Log message and return null.
log.debug("Could not resolve the value " + value + " for variable ${" + nextVariable + "}");
return null;
}
if (variableChain != null && !variableChain.isEmpty()) {
thisVariableChain.addAll(variableChain);
}

String resolvedValue = resolveVariables(log, value, thisVariableChain, props, defaultProps, libDirPropFiles);

if (resolvedValue != null) {
String escapedVariable = Matcher.quoteReplacement(nextVariable);
// For Windows, avoid escaping the backslashes in the resolvedValue by changing to forward slashes
resolvedValue = resolvedValue.replace("\\","/");
resolved = resolved.replaceAll("\\$\\{" + escapedVariable + "\\}", resolvedValue);
} else {
// Variable could not be resolved. Log message and return null.
log.debug("Variable " + nextVariable + " cannot be resolved.");
// Variable value could not be resolved. Log message and return null.
log.debug("Could not resolve the value " + value + " for variable ${" + nextVariable + "}");
return null;
}
}
Expand Down

0 comments on commit f97ef17

Please sign in to comment.