Details
-
Bug
-
Resolution: Fixed
-
P3
-
8
-
None
-
b106
-
Verified
Description
Below shows the test case that passes with JDK 7 but fails with JDK8.
If a logger of a given name exists, Logger.getLogger(name, null) throws IAE when running with JDK 7. Looks like this is related to the fix forJDK-7045594 in JDK 8 [1].
[1] http://hg.openjdk.java.net/jdk8/tl/jdk/rev/4a221501079a
----------------------------------------------------------------
import java.util.logging.*;
import java.util.*;
public class TestLogger {
public static final String RESOURCE_BUNDLE = "myresource";
public static final String FOO_LOGGER = "org.foo.Foo";
public static final String BAR_LOGGER = "org.bar.Bar";
public static final String GEE_LOGGER = "org.gee.Gee";
public static void main(String[] args) {
newLogger(FOO_LOGGER, RESOURCE_BUNDLE);
newLogger(FOO_LOGGER);
newLogger(BAR_LOGGER);
newLogger(BAR_LOGGER, RESOURCE_BUNDLE);
newLogger(GEE_LOGGER, null);
newLogger(GEE_LOGGER, RESOURCE_BUNDLE);
try {
Logger.getLogger(GEE_LOGGER, null);
throw new RuntimeException("Shouldn't allow to reset the resource bundle");
} catch (IllegalArgumentException e) {}
}
private static List<Logger> strongRefs = new ArrayList<>();
private static void newLogger(String name) {
strongRefs.add(Logger.getLogger(name));
}
private static void newLogger(String name, String resourceBundleName) {
strongRefs.add(Logger.getLogger(name, resourceBundleName));
}
}
If a logger of a given name exists, Logger.getLogger(name, null) throws IAE when running with JDK 7. Looks like this is related to the fix for
[1] http://hg.openjdk.java.net/jdk8/tl/jdk/rev/4a221501079a
----------------------------------------------------------------
import java.util.logging.*;
import java.util.*;
public class TestLogger {
public static final String RESOURCE_BUNDLE = "myresource";
public static final String FOO_LOGGER = "org.foo.Foo";
public static final String BAR_LOGGER = "org.bar.Bar";
public static final String GEE_LOGGER = "org.gee.Gee";
public static void main(String[] args) {
newLogger(FOO_LOGGER, RESOURCE_BUNDLE);
newLogger(FOO_LOGGER);
newLogger(BAR_LOGGER);
newLogger(BAR_LOGGER, RESOURCE_BUNDLE);
newLogger(GEE_LOGGER, null);
newLogger(GEE_LOGGER, RESOURCE_BUNDLE);
try {
Logger.getLogger(GEE_LOGGER, null);
throw new RuntimeException("Shouldn't allow to reset the resource bundle");
} catch (IllegalArgumentException e) {}
}
private static List<Logger> strongRefs = new ArrayList<>();
private static void newLogger(String name) {
strongRefs.add(Logger.getLogger(name));
}
private static void newLogger(String name, String resourceBundleName) {
strongRefs.add(Logger.getLogger(name, resourceBundleName));
}
}
Attachments
Issue Links
- relates to
-
JDK-7045594 fix for 6977677 introduced a ResourceBundle race
- Closed