+ * While not mandatory, this actually helps so enabling it only in the Quarkus codebase has actual value. + */ + private static void clearResourceManagerPropertiesCache() { try { - Field f = AnnotationUtils.class.getDeclaredField("repeatableAnnotationContainerCache"); - f.setAccessible(true); - ((Map) (f.get(null))).clear(); - } catch (NoSuchFieldException | IllegalAccessException e) { - //ignore - log.debug("Failed to clear annotation cache", e); + clearMap(Class.forName("com.sun.naming.internal.ResourceManager"), "propertiesCache"); + } catch (ClassNotFoundException e) { + // ignore + log.debug("Unable to load com.sun.naming.internal.ResourceManager", e); } } @@ -31,8 +40,19 @@ private static void clearBeansIntrospectorCache() { try { Introspector.flushCaches(); } catch (Exception e) { - //ignore + // ignore log.debug("Failed to clear java.beans.Introspector cache", e); } } + + private static void clearMap(Class> clazz, String mapField) { + try { + Field f = clazz.getDeclaredField(mapField); + f.setAccessible(true); + ((Map) (f.get(null))).clear(); + } catch (Exception e) { + // ignore + log.debugf(e, "Failed to clear cache for %s#%s cache", clazz.getName(), mapField); + } + } }