-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b06
Method java.util.TimeZone#setDefaultZone has catch for NullPointerException:
// if the time zone ID is not set (yet), perform the
// platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) {
String javaHome = StaticProperty.javaHome();
try {
zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) {
zoneID = GMT_ID;
}
} catch (NullPointerException e) {
zoneID = GMT_ID;
}
}
But NPE couldn't happen in try block. We can remove catch block to simplify code a bit.
// if the time zone ID is not set (yet), perform the
// platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) {
String javaHome = StaticProperty.javaHome();
try {
zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) {
zoneID = GMT_ID;
}
} catch (NullPointerException e) {
zoneID = GMT_ID;
}
}
But NPE couldn't happen in try block. We can remove catch block to simplify code a bit.
- relates to
-
JDK-4368016 TimeZone.getSystemTimeZoneID throws NPE when user.timezone property is removed
-
- Resolved
-