From ab9e13643cc8dab5554955598f247737a3965175 Mon Sep 17 00:00:00 2001 From: vharseko Date: Tue, 9 Jan 2024 21:00:56 +0300 Subject: [PATCH] FIX performance java.util.TimeZone.getTimeZone(TimeZone.java:516) is synchronized (#318) * FIX performance java.util.TimeZone.getTimeZone(TimeZone.java:516) is synchronized * workaround java.time.DateTimeException: Invalid ID for offset-based ZoneId: GMT+2359 --- .../java/org/forgerock/opendj/ldap/GeneralizedTime.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/GeneralizedTime.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/GeneralizedTime.java index 8bdfc37577..6045ac8090 100644 --- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/GeneralizedTime.java +++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/GeneralizedTime.java @@ -15,6 +15,7 @@ */ package org.forgerock.opendj.ldap; +import java.time.ZoneId; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; @@ -25,6 +26,7 @@ import org.forgerock.i18n.LocalizedIllegalArgumentException; import org.forgerock.util.Reject; + import static com.forgerock.opendj.ldap.CoreMessages.*; /** @@ -790,7 +792,11 @@ private static TimeZone getTimeZoneForOffset(final String value, final int start // If we've gotten here, then it looks like a valid offset. We can // create a time zone by using "GMT" followed by the offset. - return TimeZone.getTimeZone("GMT" + offSetStr); + try { + return TimeZone.getTimeZone(ZoneId.of("GMT"+offSetStr)); + }catch (java.time.DateTimeException e) { + return TimeZone.getTimeZone("GMT"+offSetStr); + } } /** Lazily constructed internal representations. */