From 703398bf0432cf2df16d251996757e4e4bd82b17 Mon Sep 17 00:00:00 2001 From: Brian Stansberry Date: Thu, 18 Jul 2024 10:45:51 -0500 Subject: [PATCH] [WFLY-19523] Always clear the deployment CL from WildFlyConfigurationFactory --- .../as/jaxrs/deployment/JaxrsIntegrationProcessor.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsIntegrationProcessor.java b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsIntegrationProcessor.java index 04147ac32198..0780b3ac8c95 100644 --- a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsIntegrationProcessor.java +++ b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsIntegrationProcessor.java @@ -393,19 +393,21 @@ public void undeploy(DeploymentUnit context) { //see https://issues.jboss.org/browse/WFLY-7037 //see https://github.com/FasterXML/jackson-databind/issues/1363 //we use reflection to avoid a non optional dependency on jackson + Module module = null; try { - Module module = context.getAttachment(Attachments.MODULE); + module = context.getAttachment(Attachments.MODULE); Class typeFactoryClass = module.getClassLoader().loadClass("com.fasterxml.jackson.databind.type.TypeFactory"); Method defaultInstanceMethod = typeFactoryClass.getMethod("defaultInstance"); Object typeFactory = defaultInstanceMethod.invoke(null); Method clearCache = typeFactoryClass.getDeclaredMethod("clearCache"); clearCache.invoke(typeFactory); + } catch (Exception e) { + JAXRS_LOGGER.debugf("Failed to clear class utils LRU map"); + } finally { // Remove the deployment from the registered configuration factory - if (JaxrsDeploymentMarker.isJaxrsDeployment(context)) { + if (module != null && JaxrsDeploymentMarker.isJaxrsDeployment(context)) { WildFlyConfigurationFactory.getInstance().unregister(module.getClassLoader()); } - } catch (Exception e) { - JAXRS_LOGGER.debugf("Failed to clear class utils LRU map"); } }