From 346e8c16c440f78fcc02a22bbb1e869324edbd19 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Mon, 2 Dec 2024 11:23:17 +0800 Subject: [PATCH] [JBWS-4433]:Don't create JAXPDelegateClassLoader for each invocation in the CXFServletExt --- .../src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java b/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java index 1cdad827b..287af6f0c 100644 --- a/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java +++ b/modules/server/src/main/java/org/jboss/wsf/stack/cxf/CXFServletExt.java @@ -50,6 +50,7 @@ public class CXFServletExt extends AbstractHTTPServlet implements ServletDelegate { private static final long serialVersionUID = -1820187716558491952L; + private ClassLoader delegateClassLoader; protected Endpoint endpoint; protected Bus bus; @@ -57,6 +58,8 @@ public class CXFServletExt extends AbstractHTTPServlet implements ServletDelegat public void init(ServletConfig sc) throws ServletException { super.init(sc); loadBus(sc); + delegateClassLoader = SecurityActions.createDelegateClassLoader(SecurityActions.getContextClassLoader(), + CXFServletExt.class.getClassLoader()); } protected void loadBus(ServletConfig servletConfig) throws ServletException @@ -157,7 +160,7 @@ protected Bus getBus() private ClassLoader pushServerCL() { ClassLoader current = SecurityActions.getContextClassLoader(); - SecurityActions.setContextClassLoader(SecurityActions.createDelegateClassLoader(current, CXFServletExt.class.getClassLoader())); + SecurityActions.setContextClassLoader(this.delegateClassLoader); return current; }