}
};
this.dispatch = run;
- request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+ AtomicBoolean dispatched = new AtomicBoolean(false);
+ request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, dispatched );
+ if (!dispatched.get()) {
+ try {
+ doInternalDispatch();
+ }catch (ServletException sx) {
+ throw new RuntimeException(sx);
+ }catch (IOException ix) {
+ throw new RuntimeException(ix);
+ }
+ }
} else {
throw new IllegalStateException("Dispatch not allowed. Invalid state:"+state.get());
}
};
this.dispatch = r;
- request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, null );
+ AtomicBoolean dispatched = new AtomicBoolean(false);
+ request.coyoteRequest.action(ActionCode.ACTION_ASYNC_DISPATCH, dispatched );
+ if (!dispatched.get()) {
+ try {
+ doInternalDispatch();
+ }catch (ServletException sx) {
+ throw new RuntimeException(sx);
+ }catch (IOException ix) {
+ throw new RuntimeException(ix);
+ }
+ }
} else {
throw new IllegalStateException("Dispatch not allowed. Invalid state:"+state.get());
}
attach.setTimeout(timeout);
} else if (actionCode == ActionCode.ACTION_ASYNC_DISPATCH) {
RequestInfo rp = request.getRequestProcessor();
+ AtomicBoolean dispatch = (AtomicBoolean)param;
if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) {//async handling
endpoint.processSocket(this.socket, SocketStatus.OPEN, true);
} else {
- throw new UnsupportedOperationException("Can't call dispatch on the worker thread.");
+ dispatch.set(true);
}
}
}