Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8261919: java/util/Locale/LocaleProvidersRun.java failed with "RuntimeException: Expected log was not emitted. LogRecord: null" #2683

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, 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
@@ -29,6 +29,7 @@
import java.time.format.FormatStyle;
import java.time.temporal.WeekFields;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.StreamHandler;
@@ -398,22 +399,29 @@ static void bug8232860Test() {
}

static void bug8245241Test(String expected) {
LogRecord[] lra = new LogRecord[1];
StreamHandler handler = new StreamHandler() {
// this will ensure LocaleProviderAdapter initialization
DateFormat.getDateInstance();
LogConfig.handler.flush();

if (LogConfig.logRecordList.stream()
.noneMatch(r -> r.getLevel() == Level.INFO &&
r.getMessage().equals(expected))) {
throw new RuntimeException("Expected log was not emitted.");
}
}

// Set the root logger on loading the logging class
public static class LogConfig {
final static CopyOnWriteArrayList<LogRecord> logRecordList = new CopyOnWriteArrayList<>();
final static StreamHandler handler = new StreamHandler() {
@Override
public void publish(LogRecord record) {
lra[0] = record;
logRecordList.add(record);
System.out.println("LogRecord: " + record.getMessage());
}
};
getLogManager().getLogger("").addHandler(handler);

DateFormat.getDateInstance(); // this will init LocaleProviderAdapter
handler.flush();

if (lra[0] == null ||
lra[0].getLevel() != Level.INFO ||
!lra[0].getMessage().equals(expected)) {
throw new RuntimeException("Expected log was not emitted. LogRecord: " + lra[0]);
static {
getLogManager().getLogger("").addHandler(handler);
}
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, 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
@@ -26,7 +26,7 @@
* @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577
* 8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006
* 8150432 8215913 8220227 8228465 8232871 8232860 8236495 8245241
* 8246721 8248695 8257964
* 8246721 8248695 8257964 8261919
* @summary tests for "java.locale.providers" system property
* @library /test/lib
* @build LocaleProviders
@@ -184,6 +184,7 @@ private static void testRun(String prefList, String methodName,
.addToolArg("-esa")
.addToolArg("-cp")
.addToolArg(Utils.TEST_CLASS_PATH)
.addToolArg("-Djava.util.logging.config.class=LocaleProviders$LogConfig")
.addToolArg("-Djava.locale.providers=" + prefList)
.addToolArg("--add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED")
.addToolArg("LocaleProviders")