diff --git a/build-parent/pom.xml b/build-parent/pom.xml index f1807bfca2832..371a946a9aea2 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -438,7 +438,8 @@ - ${jacoco.agent.argLine} -Xmx1500m -XX:MaxMetaspaceSize=1500m -Djava.io.tmpdir="${project.build.directory}" ${surefire.argLine.additional} + + ${jacoco.agent.argLine} -Xmx1500m -XX:MaxMetaspaceSize=1500m -Djava.io.tmpdir="${project.build.directory}" ${surefire.argLine.additional} --add-opens java.naming/com.sun.naming.internal=ALL-UNNAMED MAVEN_OPTS diff --git a/extensions/jaxb/deployment/pom.xml b/extensions/jaxb/deployment/pom.xml index a496418bac757..e4cf5cd173d01 100644 --- a/extensions/jaxb/deployment/pom.xml +++ b/extensions/jaxb/deployment/pom.xml @@ -11,6 +11,9 @@ quarkus-jaxb-deployment Quarkus - JAXB - Deployment + + -Duser.language=en + @@ -52,13 +55,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - - -Duser.language=en - - diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/ClearCache.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/ClearCache.java index 409b5e930b9f5..179ef1d5e5295 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/ClearCache.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/ClearCache.java @@ -13,17 +13,26 @@ public class ClearCache { public static void clearCaches() { clearAnnotationCache(); + clearResourceManagerPropertiesCache(); clearBeansIntrospectorCache(); } private static void clearAnnotationCache() { + clearMap(AnnotationUtils.class, "repeatableAnnotationContainerCache"); + } + + /** + * This will only be effective if the tests are launched with --add-opens java.naming/com.sun.naming.internal=ALL-UNNAMED, + * which is the case in the Quarkus codebase where memory usage is actually an issue. + *

+ * 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); + } + } }