Skip to content

Commit

Permalink
Feature: Improve automated containerized deployment
Browse files Browse the repository at this point in the history
Shielding unit test from theCaseInsensitiveEnvironment field absence (JVM dependent)

Signed-off-by: syalioune <[email protected]>
  • Loading branch information
syalioune committed Mar 2, 2023
1 parent 3af4dce commit 2ed62c7
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@ private static void clearEnvironmentVariable(String key) throws Exception {
Object unmodifiableMap = unmodifiableMapField.get(null);
clearUnmodifiableMap(key, unmodifiableMap);

Field caseInsensitiveMapField = getAccessibleField(processEnvironment, "theCaseInsensitiveEnvironment");
Map<String, String> caseInsensitiveMap = (Map<String, String>) caseInsensitiveMapField.get(null);
caseInsensitiveMap.remove(key);
try {
Field caseInsensitiveMapField = getAccessibleField(processEnvironment, "theCaseInsensitiveEnvironment");
Map<String, String> caseInsensitiveMap = (Map<String, String>) caseInsensitiveMapField.get(null);
caseInsensitiveMap.remove(key);
} catch (NoSuchFieldException e) {
e.printStackTrace();
// Nothing to be done, the attribute presence depend on the JVM
}

Field mapField = getAccessibleField(processEnvironment, "theEnvironment");
Map<String, String> map = (Map<String, String>) mapField.get(null);
Expand All @@ -154,9 +159,14 @@ private static void setEnvironmentVariable(String key, String value) throws Exce
Object unmodifiableMap = unmodifiableMapField.get(null);
injectIntoUnmodifiableMap(key, value, unmodifiableMap);

Field caseInsensitiveMapField = getAccessibleField(processEnvironment, "theCaseInsensitiveEnvironment");
Map<String, String> caseInsensitiveMap = (Map<String, String>) caseInsensitiveMapField.get(null);
caseInsensitiveMap.put(key, value);
try {
Field caseInsensitiveMapField = getAccessibleField(processEnvironment, "theCaseInsensitiveEnvironment");
Map<String, String> caseInsensitiveMap = (Map<String, String>) caseInsensitiveMapField.get(null);
caseInsensitiveMap.put(key, value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
// Nothing to be done, the attribute presence depend on the JVM
}

Field mapField = getAccessibleField(processEnvironment, "theEnvironment");
Map<String, String> map = (Map<String, String>) mapField.get(null);
Expand Down

0 comments on commit 2ed62c7

Please sign in to comment.