Skip to content

Commit

Permalink
System property should have higher priority than env option
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <[email protected]>
  • Loading branch information
dmatej committed Dec 2, 2024
1 parent 48c9d79 commit 315c37a
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public EnvToPropsConverter(final Path relativePathAnchor) {
/**
* Tries to resolve given keys.
* <ul>
* <li>First tries {@link System#getenv(String)} using map key.
* <li>Then tries {@link System#getProperty(String)} using map value.
* <li>First tries {@link System#getProperty(String)} using map value.
* <li>Then tries {@link System#getenv(String)} using map key.
* </ul>
* Then if the retrieved value is relative, it is resolved against the anchor path from
* constructor.
Expand Down Expand Up @@ -74,8 +74,8 @@ public Map<String, File> convert(final Map<String, String> envToSys) {
/**
* Tries to resolve given keys.
* <ul>
* <li>First tries {@link System#getenv(String)} using the first parameter.
* <li>Then tries {@link System#getProperty(String)} using the second parameter.
* <li>First tries {@link System#getProperty(String)} using the second parameter.
* <li>Then tries {@link System#getenv(String)} using the first parameter.
* </ul>
* Then if the retrieved value is relative, it is resolved against the anchor path from
* constructor.
Expand All @@ -91,14 +91,14 @@ public File convert(final String envPropertyName, final String systemPropertyNam


private String evaluate(final String envPropertyName, final String systemPropertyName) {
final String envValue = System.getenv(envPropertyName);
if (envValue != null) {
return envValue;
}
final String sysValue = System.getProperty(systemPropertyName);
if (sysValue != null) {
return sysValue;
}
final String envValue = System.getenv(envPropertyName);
if (envValue != null) {
return envValue;
}
// System.err.println("Missing env " + envPropertyName + " or system property " + systemPropertyName);
return null;
}
Expand Down

0 comments on commit 315c37a

Please sign in to comment.