diff --git a/sofa-boot-project/sofa-boot-core/ark-sofa-boot/src/main/java/com/alipay/sofa/boot/ark/invoke/DynamicJvmServiceInvoker.java b/sofa-boot-project/sofa-boot-core/ark-sofa-boot/src/main/java/com/alipay/sofa/boot/ark/invoke/DynamicJvmServiceInvoker.java index 9c826c519..dd04ec5f9 100644 --- a/sofa-boot-project/sofa-boot-core/ark-sofa-boot/src/main/java/com/alipay/sofa/boot/ark/invoke/DynamicJvmServiceInvoker.java +++ b/sofa-boot-project/sofa-boot-core/ark-sofa-boot/src/main/java/com/alipay/sofa/boot/ark/invoke/DynamicJvmServiceInvoker.java @@ -40,24 +40,24 @@ */ public class DynamicJvmServiceInvoker extends ServiceProxy { - private static final Logger LOGGER = SofaBootLoggerFactory - .getLogger(DynamicJvmServiceInvoker.class); + private static final Logger LOGGER = SofaBootLoggerFactory + .getLogger(DynamicJvmServiceInvoker.class); - private final Contract contract; - private final Object targetService; - private final String bizIdentity; - private final ThreadLocal clientClassloader = new ThreadLocal<>(); - private final boolean serialize; + private final Contract contract; + private final Object targetService; + private final String bizIdentity; + private final ClassLoader clientClassloader; + private final boolean serialize; - static protected final String TOSTRING_METHOD = "toString"; - static protected final String EQUALS_METHOD = "equals"; - static protected final String HASHCODE_METHOD = "hashCode"; + static protected final String TOSTRING_METHOD = "toString"; + static protected final String EQUALS_METHOD = "equals"; + static protected final String HASHCODE_METHOD = "hashCode"; public DynamicJvmServiceInvoker(ClassLoader clientClassloader, ClassLoader serviceClassLoader, Object targetService, Contract contract, String bizIdentity, boolean serialize) { super(serviceClassLoader); - this.clientClassloader.set(clientClassloader); + this.clientClassloader = clientClassloader; this.targetService = targetService; this.contract = contract; this.bizIdentity = bizIdentity; @@ -103,10 +103,10 @@ protected Object doInvoke(MethodInvocation invocation) throws Throwable { } } else { Object[] arguments = (Object[]) hessianTransport(targetArguments, null); - Class[] argumentTypes = (Class[]) hessianTransport(oldArgumentTypes, null); + Class[] argumentTypes = (Class[]) hessianTransport(oldArgumentTypes, null); transformMethod = getTargetMethod(targetMethod, argumentTypes); Object retVal = transformMethod.invoke(targetService, arguments); - return hessianTransport(retVal, getClientClassloader()); + return hessianTransport(retVal, clientClassloader); } } catch (InvocationTargetException ex) { throw ex.getTargetException(); @@ -114,7 +114,6 @@ protected Object doInvoke(MethodInvocation invocation) throws Throwable { if (DynamicJvmServiceProxyFinder.getInstance().getBizManagerService() != null) { ReplayContext.clearPlaceHolder(); } - clearClientClassloader(); } } @@ -136,18 +135,6 @@ public Class getInterfaceType() { return contract.getInterfaceType(); } - public ClassLoader getClientClassloader() { - return clientClassloader.get(); - } - - public void setClientClassloader(ClassLoader clientClassloader) { - this.clientClassloader.set(clientClassloader); - } - - public void clearClientClassloader() { - this.clientClassloader.remove(); - } - private Method getTargetMethod(Method method, Class[] argumentTypes) { try { return targetService.getClass().getMethod(method.getName(), argumentTypes);