mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
8349873: StackOverflowError after JDK-8342550 if -Duser.timezone= is set to a deprecated zone id
Reviewed-by: joehw, jlu, iris
This commit is contained in:
parent
d8fcd43a24
commit
3e7acfac48
2 changed files with 20 additions and 11 deletions
|
@ -47,7 +47,6 @@ import jdk.internal.util.StaticProperty;
|
||||||
import sun.util.calendar.ZoneInfo;
|
import sun.util.calendar.ZoneInfo;
|
||||||
import sun.util.calendar.ZoneInfoFile;
|
import sun.util.calendar.ZoneInfoFile;
|
||||||
import sun.util.locale.provider.TimeZoneNameUtility;
|
import sun.util.locale.provider.TimeZoneNameUtility;
|
||||||
import sun.util.logging.PlatformLogger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code TimeZone} represents a time zone offset, and also figures out daylight
|
* {@code TimeZone} represents a time zone offset, and also figures out daylight
|
||||||
|
@ -599,9 +598,9 @@ public abstract class TimeZone implements Serializable, Cloneable {
|
||||||
|
|
||||||
private static TimeZone getTimeZone(String ID, boolean fallback) {
|
private static TimeZone getTimeZone(String ID, boolean fallback) {
|
||||||
if (ZoneId.SHORT_IDS.containsKey(ID)) {
|
if (ZoneId.SHORT_IDS.containsKey(ID)) {
|
||||||
PlatformLogger.getLogger(TimeZone.class.getName())
|
System.err.printf(
|
||||||
.warning("Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release"
|
"WARNING: Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release%n",
|
||||||
.formatted(ID));
|
ID);
|
||||||
}
|
}
|
||||||
TimeZone tz = ZoneInfo.getTimeZone(ID);
|
TimeZone tz = ZoneInfo.getTimeZone(ID);
|
||||||
if (tz == null) {
|
if (tz == null) {
|
||||||
|
|
|
@ -23,27 +23,37 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8342550
|
* @bug 8342550 8349873
|
||||||
* @summary Three-letter time zone IDs should output a deprecated warning
|
* @summary Three-letter time zone IDs should output a deprecated warning
|
||||||
* message.
|
* message.
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @build jdk.test.lib.process.ProcessTools
|
* @build jdk.test.lib.process.ProcessTools
|
||||||
* @run main ThreeLetterZoneID
|
* @run junit ThreeLetterZoneID
|
||||||
*/
|
*/
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class ThreeLetterZoneID {
|
public class ThreeLetterZoneID {
|
||||||
public static void main(String... args) throws Exception {
|
private static final String WARNING =
|
||||||
|
"WARNING: Use of the three-letter time zone ID \"PST\" is deprecated and it will be removed in a future release";
|
||||||
|
|
||||||
|
public static void main(String... args) {
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
TimeZone.getTimeZone("PST");
|
TimeZone.getTimeZone("PST");
|
||||||
} else {
|
} else {
|
||||||
checkWarningMessage();
|
TimeZone.getDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkWarningMessage() throws Exception {
|
@Test
|
||||||
ProcessTools.executeTestJava("ThreeLetterZoneID", "dummy")
|
public void testExplicitGetTimeZone() throws Exception {
|
||||||
.shouldContain("Use of the three-letter time zone ID \"PST\" is deprecated and it will be removed in a future release");
|
ProcessTools.executeTestJava("ThreeLetterZoneID", "dummy").stderrShouldMatch(WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSysProp() throws Exception {
|
||||||
|
ProcessTools.executeTestJava("-Duser.timezone=PST", "ThreeLetterZoneID").stderrShouldMatch(WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue