Skip to content

Commit

Permalink
enhance: add zone id class cache (#115)
Browse files Browse the repository at this point in the history
Co-authored-by: lo1nt <[email protected]>
  • Loading branch information
Lo1nt and lo1nt authored Aug 12, 2024
1 parent dfcbd72 commit 1c5a171
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/com/caucho/hessian/io/SerializerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,20 @@ protected static void addAbstractStringBuilderSupport() {
}
}

private static boolean isZoneId(Class cl) {
private static Class<?> ZONE_ID_CLASS_CACHE = null;

static {
try {
return isHigherThanJdk8 && Class.forName("java.time.ZoneId").isAssignableFrom(cl);
ZONE_ID_CLASS_CACHE = Class.forName("java.time.ZoneId");
} catch (ClassNotFoundException e) {
// ignore
}
}

private static boolean isZoneId(Class cl) {
if (ZONE_ID_CLASS_CACHE != null) {
return isHigherThanJdk8 && ZONE_ID_CLASS_CACHE.isAssignableFrom(cl);
}
return false;
}
}

0 comments on commit 1c5a171

Please sign in to comment.