Skip to content

Commit

Permalink
8315696: SignedLoggerFinderTest.java test failed
Browse files Browse the repository at this point in the history
Backport-of: e409d07ae84c693b656c02befb636593f9293635
  • Loading branch information
coffeys committed Sep 19, 2023
1 parent 51d738b commit 2312578
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

1 comment on commit 2312578

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.