Skip to content

Commit

Permalink
8315696: SignedLoggerFinderTest.java test failed
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Fuchs <dfuchs@openjdk.org>
Reviewed-by: dfuchs
  • Loading branch information
coffeys and dfuch committed Sep 8, 2023
1 parent ab6a87e commit e409d07
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
Expand Up @@ -26,13 +26,12 @@
* @bug 8314263
* @summary Creating a logger while loading the Logger finder
* triggers recursion and StackOverflowError
* @modules java.base/sun.util.logging
* @library /test/lib
* @modules java.base/sun.util.logging java.base/jdk.internal.logger:+open
* @library ../lib
* @compile RecursiveLoadingTest.java SimpleLoggerFinder.java
* @run main/othervm PlatformRecursiveLoadingTest
*/


import java.time.Instant;
import java.util.Arrays;
import java.util.List;
Expand All @@ -50,6 +49,8 @@ public class PlatformRecursiveLoadingTest {
*/
public static void main(String[] args) throws Throwable {
PlatformLogger.getLogger("main").info("in main");
// allow time to let bootstrap logger flush data
BootstrapLoggerUtils.awaitPending();
List<Object> logs = loggerfinder.SimpleLoggerFinder.LOGS;
logs.stream().map(SimpleLogRecord::of).forEach(System.out::println);
logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check);
Expand Down
Expand Up @@ -26,6 +26,8 @@
* @bug 8314263
* @summary Creating a logger while loading the Logger finder
* triggers recursion and StackOverflowError
* @modules java.base/jdk.internal.logger:+open
* @library ../lib
* @compile RecursiveLoadingTest.java SimpleLoggerFinder.java
* @run main/othervm RecursiveLoadingTest
*/
Expand All @@ -45,6 +47,8 @@ public class RecursiveLoadingTest {
*/
public static void main(String[] args) throws Throwable {
System.getLogger("main").log(System.Logger.Level.INFO, "in main");
// allow time to let bootstrap logger flush data
BootstrapLoggerUtils.awaitPending();
List<Object> logs = loggerfinder.SimpleLoggerFinder.LOGS;
logs.stream().map(SimpleLogRecord::of).forEach(System.out::println);
logs.stream().map(SimpleLogRecord::of).forEach(SimpleLogRecord::check);
Expand Down
Expand Up @@ -25,7 +25,8 @@
* @test
* @bug 8314263
* @summary Signed jars triggering Logger finder recursion and StackOverflowError
* @library /test/lib
* @modules java.base/jdk.internal.logger:+open
* @library /test/lib ../lib
* @build jdk.test.lib.compiler.CompilerUtils
* jdk.test.lib.process.*
* jdk.test.lib.util.JarUtils
Expand Down Expand Up @@ -146,6 +147,8 @@ public static void main(String[] args) throws Throwable {

// LoggerFinder should be initialized, trigger a simple log call
Security.setProperty("test_2", "test");
// allow time to let bootstrap logger flush data
BootstrapLoggerUtils.awaitPending();
}
}

Expand All @@ -165,6 +168,8 @@ private static void launchTest(boolean multiThreadLoad, boolean withCustomLogger
System.getProperty("test.classes")));
}
cmds.addAll(List.of(
// allow test to access internal bootstrap logger functionality
"--add-opens=java.base/jdk.internal.logger=ALL-UNNAMED",
// following debug property seems useful to tickle the issue
"-Dsun.misc.URLClassPath.debug=true",
// console logger level to capture event output
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,7 +29,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;

import jdk.internal.logger.BootstrapLogger;
import jdk.internal.logger.LazyLoggers;

Expand All @@ -38,9 +38,10 @@
* @bug 8144460 8144214
* @summary Cover the logXX and LogEvent.valueOf APIs of BootstrapLogger
* and logXX APIs of SimpleConsoleLogger.
* @library ../../lib
* @modules java.base/jdk.internal.logger:+open
* java.base/sun.util.logging
* @build BootstrapLoggerUtils LogStream
* @build LogStream
* @run main/othervm BootstrapLoggerAPIsTest
*/

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -53,9 +53,10 @@
* @summary JDK implementation specific unit test for JDK internal artifacts.
Tests the behavior of bootstrap loggers (and SimpleConsoleLoggers
* too).
* @library ../../lib
* @modules java.base/jdk.internal.logger:+open
* java.logging
* @build BootstrapLoggerUtils LogStream
* @build LogStream
* @run main/othervm BootstrapLoggerTest NO_SECURITY
* @run main/othervm -Djava.security.manager=allow BootstrapLoggerTest SECURE
* @run main/othervm/timeout=120 -Djava.security.manager=allow BootstrapLoggerTest SECURE_AND_WAIT
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -25,8 +25,6 @@
import java.io.OutputStream;
import java.io.PrintStream;

import jdk.internal.logger.BootstrapLogger;

/**
* We use an instance of this class to check what the logging system has printed
* on System.err.
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,7 +28,7 @@

import jdk.internal.logger.BootstrapLogger;

class BootstrapLoggerUtils {
public final class BootstrapLoggerUtils {

private static final Field IS_BOOTED;
private static final Method AWAIT_PENDING;
Expand All @@ -46,11 +46,11 @@ class BootstrapLoggerUtils {
}
}

static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException {
public static void setBootedHook(BooleanSupplier supplier) throws IllegalAccessException {
IS_BOOTED.set(null, supplier);
}

static void awaitPending() {
public static void awaitPending() {
try {
AWAIT_PENDING.invoke(null);
} catch (IllegalAccessException | IllegalArgumentException
Expand Down

3 comments on commit e409d07

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coffeys
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on e409d07 Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coffeys the backport was successfully created on the branch coffeys-backport-e409d07a in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit e409d07a from the openjdk/jdk repository.

The commit being backported was authored by Sean Coffey on 8 Sep 2023 and was reviewed by Daniel Fuchs.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git coffeys-backport-e409d07a:coffeys-backport-e409d07a
$ git checkout coffeys-backport-e409d07a
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git coffeys-backport-e409d07a

Please sign in to comment.