Skip to content

Commit 4bc34bf

Browse files
Add debug messages when getting existing value
1 parent 8c22696 commit 4bc34bf

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -1315,11 +1315,17 @@ private void updateProviders(String profileExtensionId, List<String> allInfo) {
13151315
}
13161316

13171317
private String getExistingValue(String property) {
1318+
if (debug != null) {
1319+
debug.println("\tGetting previous value of property: " + property);
1320+
}
1321+
13181322
// Look for values from profiles that this one extends.
13191323
String existingValue = profileProperties.get(property);
1324+
String debugMessage = "\t\tPrevious value from extended profile: ";
13201325

13211326
// If there is no value, look for non-profile values in java.security file.
13221327
if (existingValue == null) {
1328+
debugMessage = "\t\tPrevious value from java.security file: ";
13231329
String propertyKey = null;
13241330
switch (property) {
13251331
case "jdkCertpathDisabledAlgorithms":
@@ -1342,6 +1348,11 @@ private String getExistingValue(String property) {
13421348
}
13431349
existingValue = securityProps.getProperty(propertyKey);
13441350
}
1351+
1352+
if ((debug != null) && existingValue != null) {
1353+
debug.println(debugMessage + existingValue);
1354+
}
1355+
13451356
return existingValue;
13461357
}
13471358

@@ -1626,7 +1637,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16261637

16271638
// Take existing value of property into account, if applicable.
16281639
if (existingValue == null) {
1629-
printStackTraceAndExit("Property '" + property + "' does not exist in parent profile. Cannot append.");
1640+
printStackTraceAndExit("Property '" + property + "' does not exist in"
1641+
+ " parent profile or java.security file. Cannot append.");
16301642
} else if (existingValue.isBlank()) {
16311643
newValue = value;
16321644
} else {
@@ -1640,6 +1652,10 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16401652
// Remove values from property.
16411653
value = value.substring(1).trim();
16421654
if (!value.isBlank()) {
1655+
if (existingValue == null) {
1656+
printStackTraceAndExit("Property '" + property + "' does not exist in"
1657+
+ " parent profile or java.security file. Cannot remove.");
1658+
}
16431659
List<String> existingValues = Stream.of(existingValue.split(","))
16441660
.map(v -> v.trim())
16451661
.collect(Collectors.toList());
@@ -1653,7 +1669,8 @@ private boolean setProperty(String property, String propertyKey, List<String> al
16531669
} else {
16541670
// Nothing to do. Use existing value of property into account, if available.
16551671
if (existingValue == null) {
1656-
printStackTraceAndExit("Property '" + property + "' does not exist in parent profile. Cannot remove.");
1672+
printStackTraceAndExit("Property '" + property + "' does not exist in"
1673+
+ " parent profile or java.security file. Cannot remove.");
16571674
} else if (existingValue.isBlank()) {
16581675
newValue = value;
16591676
} else {

0 commit comments

Comments
 (0)