mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +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.ZoneInfoFile;
|
||||
import sun.util.locale.provider.TimeZoneNameUtility;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* {@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) {
|
||||
if (ZoneId.SHORT_IDS.containsKey(ID)) {
|
||||
PlatformLogger.getLogger(TimeZone.class.getName())
|
||||
.warning("Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release"
|
||||
.formatted(ID));
|
||||
System.err.printf(
|
||||
"WARNING: Use of the three-letter time zone ID \"%s\" is deprecated and it will be removed in a future release%n",
|
||||
ID);
|
||||
}
|
||||
TimeZone tz = ZoneInfo.getTimeZone(ID);
|
||||
if (tz == null) {
|
||||
|
|
|
@ -23,27 +23,37 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8342550
|
||||
* @bug 8342550 8349873
|
||||
* @summary Three-letter time zone IDs should output a deprecated warning
|
||||
* message.
|
||||
* @library /test/lib
|
||||
* @build jdk.test.lib.process.ProcessTools
|
||||
* @run main ThreeLetterZoneID
|
||||
* @run junit ThreeLetterZoneID
|
||||
*/
|
||||
import java.util.TimeZone;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
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) {
|
||||
TimeZone.getTimeZone("PST");
|
||||
} else {
|
||||
checkWarningMessage();
|
||||
TimeZone.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkWarningMessage() throws Exception {
|
||||
ProcessTools.executeTestJava("ThreeLetterZoneID", "dummy")
|
||||
.shouldContain("Use of the three-letter time zone ID \"PST\" is deprecated and it will be removed in a future release");
|
||||
@Test
|
||||
public void testExplicitGetTimeZone() throws Exception {
|
||||
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