Skip to content
Permalink
Browse files
[CXF-5414] If a continuation is complete, make sure we let he contain…
…er know so timeouts will cancel.

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1544608 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Nov 22, 2013
1 parent fce0ce3 commit 3d210220f02839cd8388e36f2ae9e6bf645cbdd7
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 1 deletion.
@@ -30,4 +30,9 @@ public interface ContinuationProvider {
* @return transport-neutral ContinuationWrapper
*/
Continuation getContinuation();

/**
* Let the provider know that the exchange is complete
*/
void complete();
}
@@ -287,6 +287,10 @@ protected void serviceRequest(final ServletContext context,
incomingObserver.onMessage(inMessage);
resp.flushBuffer();
baseRequest.setHandled(true);
ContinuationProvider p = inMessage.get(ContinuationProvider.class);
if (p != null) {
p.complete();
}
} catch (SuspendedInvocationException ex) {
if (ex.getRuntimeException() != null) {
throw ex.getRuntimeException();
@@ -40,6 +40,14 @@ public JettyContinuationProvider(HttpServletRequest req,
response = resp;
this.inMessage = m;
}

public void complete() {
JettyContinuationWrapper r = getContinuation(false);
if (r != null) {
r.reset();
}
wrapper = null;
}
public Continuation getContinuation() {
return getContinuation(true);
}
@@ -25,15 +25,18 @@
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.continuations.SuspendedInvocationException;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.ExchangeImpl;
@@ -208,7 +211,12 @@ protected void serviceRequest(final ServletContext context,

try {
incomingObserver.onMessage(inMessage);

resp.flushBuffer();
ContinuationProvider p = inMessage.get(ContinuationProvider.class);
if (p != null) {
p.complete();
}
} catch (SuspendedInvocationException ex) {
if (ex.getRuntimeException() != null) {
throw ex.getRuntimeException();
@@ -238,6 +238,10 @@ public void invoke(final ServletConfig config,

try {
incomingObserver.onMessage(inMessage);
ContinuationProvider p = inMessage.get(ContinuationProvider.class);
if (p != null) {
p.complete();
}
} catch (SuspendedInvocationException ex) {
if (ex.getRuntimeException() != null) {
throw ex.getRuntimeException();
@@ -48,6 +48,14 @@ public Servlet3ContinuationProvider(HttpServletRequest req,
this.req = req;
this.resp = resp;
}

public void complete() {
if (continuation != null) {
continuation.reset();
continuation = null;
}
}


/** {@inheritDoc}*/
public Continuation getContinuation() {
@@ -77,7 +85,7 @@ public Servlet3Continuation() {
context = req.startAsync(req, resp);
context.addListener(this);
}

void startAsyncAgain() {

AsyncContext old = context;
@@ -51,6 +51,12 @@ public JMSContinuationProvider(Bus b,
this.jmsListener = jmsListener;
this.jmsConfig = jmsConfig;
}
public void complete() {
JMSContinuation cw = inMessage.get(JMSContinuation.class);
if (cw != null) {
cw.reset();
}
}

public Continuation getContinuation() {
Message m = inMessage;

0 comments on commit 3d21022

Please sign in to comment.