8231387: java.security.Provider.getService returns random result due to race condition with mutating methods in the same class

Synchronize access to legacyMap in Provider.getService.

Reviewed-by: valeriep
This commit is contained in:
Tianmin Shi 2019-09-25 08:29:03 -07:00 committed by Paul Hohensee
parent 3fab0b8407
commit 2b56811616
2 changed files with 101 additions and 3 deletions

View file

@ -1255,9 +1255,9 @@ public abstract class Provider extends Properties {
}
synchronized (this) {
ensureLegacyParsed();
}
if (legacyMap != null && !legacyMap.isEmpty()) {
return legacyMap.get(key);
if (legacyMap != null && !legacyMap.isEmpty()) {
return legacyMap.get(key);
}
}
return null;
}