Author: richard.opalka(a)jboss.com
Date: 2012-11-14 06:00:28 -0500 (Wed, 14 Nov 2012)
New Revision: 16982
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
Log:
[JBPAPP-10410] fix endpoint instantiation concurrency issue
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2012-11-14
10:20:57 UTC (rev 16981)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java 2012-11-14
11:00:28 UTC (rev 16982)
@@ -247,14 +247,6 @@
Throwable targetEx = th.getTargetException();
throw (targetEx instanceof Exception ? (Exception)targetEx : new
UndeclaredThrowableException(targetEx));
}
- finally
- {
- // JBWS-2486
- if (endpoint.getAttachment(Object.class) == null)
- {
- endpoint.addAttachment(Object.class,
inv.getInvocationContext().getTargetBean());
- }
- }
// Handler processing might have replaced the endpoint invocation
sepInv =
inv.getInvocationContext().getAttachment(EndpointInvocation.class);
@@ -363,12 +355,35 @@
Invocation wsInv = new DelegatingInvocation();
wsInv.setInvocationContext(invContext);
wsInv.setJavaMethod(getImplMethod(endpoint, epInv));
- // JBWS-2486, see endpoint attachment initialization above
- wsInv.getInvocationContext().setTargetBean(endpoint.getAttachment(Object.class));
+ wsInv.getInvocationContext().setTargetBean(getEndpointInstance());
return wsInv;
}
+ // JBWS-2486 - Only one webservice endpoint instance can be created!
+ private Object getEndpointInstance()
+ {
+ synchronized(endpoint)
+ {
+ Object endpointImpl = endpoint.getAttachment(Object.class);
+ if (endpointImpl == null)
+ {
+ try
+ {
+ // create endpoint instance
+ final Class<?> endpointImplClass = endpoint.getTargetBeanClass();
+ endpointImpl = endpointImplClass.newInstance();
+ endpoint.addAttachment(Object.class, endpointImpl);
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot create endpoint instance:
", ex);
+ }
+ }
+ return endpointImpl;
+ }
+ }
+
protected Method getImplMethod(Endpoint endpoint, EndpointInvocation sepInv) throws
ClassNotFoundException, NoSuchMethodException
{
Class implClass = endpoint.getTargetBeanClass();
Show replies by date