Skip to content

Commit

Permalink
remove old way of overriding env var which is now deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Dec 14, 2023
1 parent 5904b3c commit 17887d0
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions std-bits/base/src/main/java/org/enso/base/Environment_Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,6 @@ public static String get_environment_variable(String name) {
}
}

/**
* Calls `action` with the provided environment variable.
*
* <p>The override is not persisted (its only visible from within the action called by this
* method) and it is only visible by the Enso `Environment.get` method (backed by {@code
* get_environment_variable}).
*
* <p>This is an internal function that should be used very carefully and only for testing.
*/
public static <T> T with_environment_variable_override(
String name, String value, Function<Object, T> action) {
String oldValue = overrides.put(name, value);
boolean was_set = oldValue != null;
try {
// Giving 0 here as an argument, as using null would lead to incorrect behaviour, due to some
// weird Truffle peculiarity.
return action.apply(0);
} finally {
if (was_set) {
overrides.put(name, oldValue);
} else {
overrides.remove(name);
}
}
}

public static void setOverride(String name, String value) {
overrides.put(name, value);
}
Expand Down

0 comments on commit 17887d0

Please sign in to comment.