Skip to content

Commit

Permalink
Merge pull request #18406 from pshipton/loggerfinder
Browse files Browse the repository at this point in the history
Don't cache instances of TemporaryLoggerFinder
  • Loading branch information
keithc-ca committed Nov 6, 2023
2 parents 60b2e21 + 1c58723 commit 4acf608
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions jcl/src/java.base/share/classes/java/lang/System.java
Expand Up @@ -1793,13 +1793,22 @@ public Logger getLocalizedLogger(String loggerName, ResourceBundle bundle, Modul
*/
public static LoggerFinder getLoggerFinder() {
verifyPermissions();
if (loggerFinder == null) {
loggerFinder = AccessController.doPrivileged(
LoggerFinder localFinder = loggerFinder;
if (localFinder == null) {
localFinder = AccessController.doPrivileged(
(PrivilegedAction<LoggerFinder>) () -> jdk.internal.logger.LoggerFinderLoader.getLoggerFinder(),
AccessController.getContext(),
com.ibm.oti.util.RuntimePermissions.permissionLoggerFinder);
/*[IF JAVA_SPEC_VERSION >= 17]*/
/*[IF JAVA_SPEC_VERSION != 21] Temporary until jdk21 picks up the OpenJDK change */
if (localFinder instanceof jdk.internal.logger.LoggerFinderLoader.TemporaryLoggerFinder) {
return localFinder;
}
/*[ENDIF] JAVA_SPEC_VERSION != 21 */
/*[ENDIF] JAVA_SPEC_VERSION >= 17 */
loggerFinder = localFinder;
}
return loggerFinder;
return localFinder;
}

private static void verifyPermissions() {
Expand Down

0 comments on commit 4acf608

Please sign in to comment.