Skip to content

Commit 1c5a171

Browse files
Lo1ntlo1nt
andauthored
enhance: add zone id class cache (#115)
Co-authored-by: lo1nt <[email protected]>
1 parent dfcbd72 commit 1c5a171

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/java/com/caucho/hessian/io/SerializerFactory.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,20 @@ protected static void addAbstractStringBuilderSupport() {
760760
}
761761
}
762762

763-
private static boolean isZoneId(Class cl) {
763+
private static Class<?> ZONE_ID_CLASS_CACHE = null;
764+
765+
static {
764766
try {
765-
return isHigherThanJdk8 && Class.forName("java.time.ZoneId").isAssignableFrom(cl);
767+
ZONE_ID_CLASS_CACHE = Class.forName("java.time.ZoneId");
766768
} catch (ClassNotFoundException e) {
767769
// ignore
768770
}
771+
}
772+
773+
private static boolean isZoneId(Class cl) {
774+
if (ZONE_ID_CLASS_CACHE != null) {
775+
return isHigherThanJdk8 && ZONE_ID_CLASS_CACHE.isAssignableFrom(cl);
776+
}
769777
return false;
770778
}
771779
}

0 commit comments

Comments
 (0)