diff --git a/src/java.base/share/classes/java/time/ZoneOffset.java b/src/java.base/share/classes/java/time/ZoneOffset.java index b35979133103a..520a0e0b9a194 100644 --- a/src/java.base/share/classes/java/time/ZoneOffset.java +++ b/src/java.base/share/classes/java/time/ZoneOffset.java @@ -429,7 +429,9 @@ public static ZoneOffset ofTotalSeconds(int totalSeconds) { if (result == null) { result = new ZoneOffset(totalSeconds); var existing = SECONDS_CACHE.putIfAbsent(totalSecs, result); - return (existing != null) ? existing : result; + if (existing != null) { + result = existing; + } ID_CACHE.putIfAbsent(result.getId(), result); } return result;