Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't allow setting a stream timeout on WF 8.2
Setting a stream timeout triggers the same session deadlock bug as async
sending in WF 8.2, so we throw if you try to use it in 8.2. This
requires changing the init order of the stream, because if we throw
after the request is converted to async, we can never return a response
to the client.
  • Loading branch information
tobias committed Aug 10, 2015
1 parent e9d268d commit ddac4fc
Showing 1 changed file with 20 additions and 4 deletions.
Expand Up @@ -35,10 +35,15 @@ public ServletHttpChannel(final HttpServletRequest request,
final OnClose onClose,
final boolean asyncSupported){
super(onOpen, onError, onClose);
this.request = request;
this.response = response;
this.asyncContext = request.startAsync();
this.asyncContext.setTimeout(0);
this.asyncSupported = asyncSupported;

}

private void open() {
this.asyncContext = request.startAsync();
this.asyncContext.setTimeout(this.timeout);
this.asyncContext.addListener(new AsyncListener() {
@Override
public void onComplete(AsyncEvent event) throws IOException {
Expand Down Expand Up @@ -94,6 +99,12 @@ void enqueue(PendingSend pending) {
}
}

@Override
public void notifyOpen(final Object context) {
open();
super.notifyOpen(context);
}

@Override
public void close() throws IOException {
this.asyncContext.complete();
Expand All @@ -103,13 +114,18 @@ public void close() throws IOException {
@Override
public void setTimeout(long timeout) {
if (timeout >= 0) {
this.asyncContext.setTimeout(timeout);
if (!this.asyncSupported) {
throw new IllegalArgumentException("HTTP stream timeouts are not supported on this platform");
}
this.timeout = timeout;
}
}

private final HttpServletRequest request;
private final HttpServletResponse response;
private final AsyncContext asyncContext;
private final boolean asyncSupported;
private long timeout = 0;
private AsyncContext asyncContext;

private static final Logger log = Logger.getLogger("org.projectodd.wunderboss.web.async");
}

0 comments on commit ddac4fc

Please sign in to comment.