Skip to content

Commit bc9535e

Browse files
committed
svm: only register valid services [GR-40544]
1 parent 4115f50 commit bc9535e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,12 +612,23 @@ private static Map<String, Set<Service>> computeAvailableServices() {
612612
Map<String, Set<Service>> availableServices = new HashMap<>();
613613
for (Provider provider : Security.getProviders()) {
614614
for (Service s : provider.getServices()) {
615-
availableServices.computeIfAbsent(s.getType(), t -> new HashSet<>()).add(s);
615+
if (isValid(s)) {
616+
availableServices.computeIfAbsent(s.getType(), t -> new HashSet<>()).add(s);
617+
}
616618
}
617619
}
618620
return availableServices;
619621
}
620622

623+
/**
624+
* Check is service is valid. See {@code java.security.Provider.Service#isValid()}.
625+
*
626+
* Presumably, this is only needed due to an upstream bug introduced in JDK 19 [GR-40544].
627+
*/
628+
private static boolean isValid(Service s) {
629+
return (s.getType() != null) && (s.getAlgorithm() != null) && (s.getClassName() != null);
630+
}
631+
621632
/**
622633
* Return a Function which given the serviceType as a String will return the corresponding
623634
* constructor parameter Class, or null.

0 commit comments

Comments
 (0)