Author: dkulp
Date: Fri Jun 15 10:17:17 2007
New Revision: 547747
URL: http://svn.apache.org/viewvc?view=rev&rev=547747
Log:
Updates for servlet memory leaks, chain caching client side.
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
incubator/cxf/trunk/maven-plugins/archetypes/cxf-http-basic/ (props
changed)
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
Modified:
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
(original)
+++
incubator/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseChainCache.java
Fri Jun 15 10:17:17 2007
@@ -107,7 +107,7 @@
return false;
}
- if (providers[x] instanceof ModCountCopyOnWriteArrayList) {
+ if (providers[x].getClass() ==
ModCountCopyOnWriteArrayList.class) {
if
(((ModCountCopyOnWriteArrayList)providers[x]).getModCount()
!= lists.get(x).getModCount()) {
return false;
Modified:
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
(original)
+++
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ModCountCopyOnWriteArrayList.java
Fri Jun 15 10:17:17 2007
@@ -22,7 +22,7 @@
import java.util.Collection;
import java.util.concurrent.CopyOnWriteArrayList;
-public class ModCountCopyOnWriteArrayList<T> extends CopyOnWriteArrayList<T> {
+public final class ModCountCopyOnWriteArrayList<T> extends
CopyOnWriteArrayList<T> {
int modCount;
public ModCountCopyOnWriteArrayList() {
@@ -35,11 +35,11 @@
}
}
- public final int getModCount() {
+ public int getModCount() {
return modCount;
}
- public final void setModCount(int i) {
+ public void setModCount(int i) {
modCount = i;
}
Propchange: incubator/cxf/trunk/maven-plugins/archetypes/cxf-http-basic/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun 15 10:17:17 2007
@@ -0,0 +1,10 @@
+.pmd
+.checkstyle
+.ruleset
+target
+.settings
+.classpath
+.project
+.wtpmodules
+
+
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
Fri Jun 15 10:17:17 2007
@@ -45,6 +45,7 @@
import org.apache.cxf.message.ExchangeImpl;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.phase.PhaseChainCache;
import org.apache.cxf.phase.PhaseInterceptorChain;
import org.apache.cxf.phase.PhaseManager;
import org.apache.cxf.service.Service;
@@ -72,6 +73,9 @@
protected ConduitSelector conduitSelector;
protected ClientOutFaultObserver outFaultObserver;
protected int synchronousTimeout = 10000; // default 10 second timeout
+
+ protected PhaseChainCache outboundChainCache = new PhaseChainCache();
+ protected PhaseChainCache inboundChainCache = new PhaseChainCache();
public ClientImpl(Bus b, Endpoint e) {
this(b, e, (ConduitSelector)null);
@@ -355,29 +359,30 @@
message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
PhaseManager pm = bus.getExtension(PhaseManager.class);
- PhaseInterceptorChain chain = new
PhaseInterceptorChain(pm.getInPhases());
- message.setInterceptorChain(chain);
- List<Interceptor> il = bus.getInInterceptors();
+
+
+ List<Interceptor> i1 = bus.getInInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by bus: " + il);
+ LOG.fine("Interceptors contributed by bus: " + i1);
}
- chain.add(il);
- il = endpoint.getInInterceptors();
+ List<Interceptor> i2 = endpoint.getInInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by endpoint: " + il);
+ LOG.fine("Interceptors contributed by endpoint: " + i2);
}
- chain.add(il);
- il = getInInterceptors();
+ List<Interceptor> i3 = getInInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by client: " + il);
+ LOG.fine("Interceptors contributed by client: " + i3);
}
- chain.add(il);
- il = endpoint.getBinding().getInInterceptors();
+ List<Interceptor> i4 = endpoint.getBinding().getInInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by binding: " + il);
+ LOG.fine("Interceptors contributed by binding: " + i4);
}
- chain.add(il);
+
+ PhaseInterceptorChain chain = inboundChainCache.get(pm.getInPhases(),
i1, i2, i3, i4);
+ message.setInterceptorChain(chain);
+
+
chain.setFaultObserver(outFaultObserver);
// execute chain
@@ -450,29 +455,24 @@
protected PhaseInterceptorChain setupInterceptorChain(Endpoint endpoint) {
PhaseManager pm = bus.getExtension(PhaseManager.class);
- PhaseInterceptorChain chain = new
PhaseInterceptorChain(pm.getOutPhases());
- List<Interceptor> il = bus.getOutInterceptors();
+ List<Interceptor> i1 = bus.getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by bus: " + il);
+ LOG.fine("Interceptors contributed by bus: " + i1);
}
- chain.add(il);
- il = endpoint.getOutInterceptors();
+ List<Interceptor> i2 = endpoint.getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by endpoint: " + il);
+ LOG.fine("Interceptors contributed by endpoint: " + i2);
}
- chain.add(il);
- il = getOutInterceptors();
+ List<Interceptor> i3 = getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by client: " + il);
+ LOG.fine("Interceptors contributed by client: " + i3);
}
- chain.add(il);
- il = endpoint.getBinding().getOutInterceptors();
+ List<Interceptor> i4 = endpoint.getBinding().getOutInterceptors();
if (LOG.isLoggable(Level.FINE)) {
- LOG.fine("Interceptors contributed by binding: " + il);
+ LOG.fine("Interceptors contributed by binding: " + i4);
}
- chain.add(il);
- return chain;
+ return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4);
}
protected void modifyChain(InterceptorChain chain, Map<String, Object>
ctx) {
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerImpl.java
Fri Jun 15 10:17:17 2007
@@ -143,6 +143,7 @@
((MultipleEndpointObserver) mo).getEndpoints().remove(endpoint);
} else {
getDestination().setMessageObserver(null);
+ getDestination().shutdown();
}
if (null != serverRegistry) {
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServerLifeCycleManagerImpl.java
Fri Jun 15 10:17:17 2007
@@ -19,14 +19,15 @@
package org.apache.cxf.endpoint;
-import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.cxf.extension.BusExtension;
public class ServerLifeCycleManagerImpl implements ServerLifeCycleManager,
BusExtension {
- private List<ServerLifeCycleListener> listeners = new
ArrayList<ServerLifeCycleListener>();
+ private List<ServerLifeCycleListener> listeners =
+ new CopyOnWriteArrayList<ServerLifeCycleListener>();
public Class<?> getRegistrationType() {
return ServerLifeCycleManager.class;
@@ -37,25 +38,13 @@
}
public void startServer(Server server) {
- List<ServerLifeCycleListener> listenersToNotify = null;
- synchronized (this) {
- listenersToNotify = new ArrayList<ServerLifeCycleListener>();
- listenersToNotify.addAll(listeners);
- }
-
- for (ServerLifeCycleListener listener : listenersToNotify) {
+ for (ServerLifeCycleListener listener : listeners) {
listener.startServer(server);
}
}
public void stopServer(Server server) {
- List<ServerLifeCycleListener> listenersToNotify = null;
- synchronized (this) {
- listenersToNotify = new ArrayList<ServerLifeCycleListener>();
- listenersToNotify.addAll(listeners);
- }
-
- for (ServerLifeCycleListener listener : listenersToNotify) {
+ for (ServerLifeCycleListener listener : listeners) {
listener.stopServer(server);
}
}
Modified:
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
(original)
+++
incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/workqueue/AutomaticWorkQueueTest.java
Fri Jun 15 10:17:17 2007
@@ -328,7 +328,7 @@
@Test
public void testShutdown() {
workqueue = new AutomaticWorkQueueImpl(DEFAULT_MAX_QUEUE_SIZE,
INITIAL_SIZE,
- INITIAL_SIZE, INITIAL_SIZE,
250);
+ INITIAL_SIZE, INITIAL_SIZE,
500);
assertEquals(0, workqueue.getSize());
DeadLockThread dead = new DeadLockThread(workqueue, 100, 5L);
Modified:
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
(original)
+++
incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WebFaultOutInterceptor.java
Fri Jun 15 10:17:17 2007
@@ -47,12 +47,31 @@
public WebFaultOutInterceptor() {
super(Phase.PRE_PROTOCOL);
}
+
+ private QName getFaultName(WebFault wf) {
+ return new QName(wf.targetNamespace(), wf.name());
+ }
+
+ private WebFault getWebFaultAnnotation(Class<?> t) {
+ WebFault fault = t.getAnnotation(WebFault.class);
+ if (fault == null
+ && t.getSuperclass() != null
+ && Throwable.class.isAssignableFrom(t.getSuperclass())) {
+ fault = getWebFaultAnnotation(t.getSuperclass());
+ }
+ return fault;
+ }
+
public void handleMessage(Message message) throws Fault {
Fault f = (Fault)message.getContent(Exception.class);
Throwable cause = f.getCause();
- if (cause instanceof Exception &&
cause.getClass().isAnnotationPresent(WebFault.class)) {
+ WebFault fault = null;
+ if (cause != null) {
+ fault = getWebFaultAnnotation(cause.getClass());
+ }
+ if (cause instanceof Exception && fault != null) {
Exception ex = (Exception)cause;
try {
Method method = cause.getClass().getMethod("getFaultInfo", new
Class[0]);
@@ -63,7 +82,7 @@
DataWriter<Node> writer =
service.getDataBinding().createWriter(Node.class);
OperationInfo op =
message.getExchange().get(BindingOperationInfo.class).getOperationInfo();
- QName faultName = getFaultName(ex);
+ QName faultName = getFaultName(fault);
MessagePartInfo part = getFaultMessagePart(faultName, op);
writer.write(faultInfo, part, f.getOrCreateDetail());
@@ -80,12 +99,6 @@
}
}
- private QName getFaultName(Exception webFault) {
- WebFault wf = webFault.getClass().getAnnotation(WebFault.class);
-
- return new QName(wf.targetNamespace(), wf.name());
- }
-
private MessagePartInfo getFaultMessagePart(QName qname, OperationInfo op)
{
for (FaultInfo faultInfo : op.getFaults()) {
for (MessagePartInfo mpi : faultInfo.getMessageParts()) {
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
(original)
+++
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Fri Jun 15 10:17:17 2007
@@ -40,6 +40,8 @@
private static final long serialVersionUID = 1L;
+ final ServletTransportFactory factory;
+ final String path;
/**
* Constructor, allowing subsititution of configuration.
@@ -52,10 +54,14 @@
*/
public ServletDestination(Bus b,
ConduitInitiator ci,
- EndpointInfo ei)
+ EndpointInfo ei,
+ ServletTransportFactory fact,
+ String p)
throws IOException {
// would add the default port to the address
super(b, ci, ei, false);
+ factory = fact;
+ path = p;
}
@@ -94,10 +100,17 @@
incomingObserver.onMessage(inMessage);
} finally {
- if (LOG.isLoggable(Level.INFO)) {
- LOG.info("Finished servicing http request on thread: " +
Thread.currentThread());
+ if (LOG.isLoggable(Level.FINE)) {
+ LOG.fine("Finished servicing http request on thread: " +
Thread.currentThread());
}
}
+ }
+
+ @Override
+ public void shutdown() {
+ factory.removeDestination(path);
+
+ super.shutdown();
}
public MessageObserver getMessageObserver() {
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?view=diff&rev=547747&r1=547746&r2=547747
==============================================================================
---
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
(original)
+++
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
Fri Jun 15 10:17:17 2007
@@ -58,12 +58,17 @@
this.bus = bus;
}
+ public void removeDestination(String path) {
+ destinations.remove(path);
+ }
+
public Destination getDestination(EndpointInfo endpointInfo)
throws IOException {
ServletDestination d =
getDestinationForPath(endpointInfo.getAddress());
if (d == null) {
- d = new ServletDestination(bus, null, endpointInfo);
- destinations.put(getTrimmedPath(endpointInfo.getAddress()), d);
+ String path = getTrimmedPath(endpointInfo.getAddress());
+ d = new ServletDestination(bus, null, endpointInfo, this, path);
+ destinations.put(path, d);
}
return d;
}
@@ -73,7 +78,7 @@
return destinations.get(getTrimmedPath(path));
}
- private String getTrimmedPath(String path) {
+ static String getTrimmedPath(String path) {
if (path == null) {
return "/";
}