MCPcopy Index your code
hub / github.com/apache/tomcat / dispatch

Method dispatch

java/org/apache/coyote/AbstractProcessor.java:227–299  ·  view source on GitHub ↗
(SocketEvent status)

Source from the content-addressed store, hash-verified

225
226
227 @Override
228 public final SocketState dispatch(SocketEvent status) throws IOException {
229
230 if (status == SocketEvent.OPEN_WRITE && response.getWriteListener() != null) {
231 asyncStateMachine.asyncOperation();
232 try {
233 if (flushBufferedWrite()) {
234 return SocketState.LONG;
235 }
236 } catch (IOException ioe) {
237 if (getLog().isDebugEnabled()) {
238 getLog().debug(sm.getString("abstractProcessor.asyncFail"), ioe);
239 }
240 status = SocketEvent.ERROR;
241 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
242 }
243 } else if (status == SocketEvent.OPEN_READ && request.getReadListener() != null) {
244 dispatchNonBlockingRead();
245 } else if (status == SocketEvent.ERROR) {
246 // An I/O error occurred on a non-container thread. This includes:
247 // - read/write timeouts fired by the Poller in NIO
248 // - completion handler failures in NIO2
249
250 if (request.getAttribute(RequestDispatcher.ERROR_EXCEPTION) == null) {
251 // Because the error did not occur on a container thread the
252 // request's error attribute has not been set. If an exception
253 // is available from the socketWrapper, use it to set the
254 // request's error attribute here so it is visible to the error
255 // handling.
256 request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, socketWrapper.getError());
257 }
258
259 if (request.getReadListener() != null || response.getWriteListener() != null) {
260 // The error occurred during non-blocking I/O. Set the correct
261 // state else the error handling will trigger an ISE.
262 asyncStateMachine.asyncOperation();
263 }
264 }
265
266 RequestInfo rp = request.getRequestProcessor();
267 try {
268 rp.setStage(Constants.STAGE_SERVICE);
269 if (!getAdapter().asyncDispatch(request, response, status)) {
270 setErrorState(ErrorState.CLOSE_NOW, null);
271 }
272 } catch (InterruptedIOException e) {
273 setErrorState(ErrorState.CLOSE_CONNECTION_NOW, e);
274 } catch (Throwable t) {
275 ExceptionUtils.handleThrowable(t);
276 setErrorState(ErrorState.CLOSE_NOW, t);
277 getLog().error(sm.getString("http11processor.request.process"), t);
278 }
279
280 rp.setStage(Constants.STAGE_ENDED);
281
282 SocketState state;
283
284 if (getErrorState().isError()) {

Callers

nothing calls this directly

Calls 15

flushBufferedWriteMethod · 0.95
setStageMethod · 0.95
getAdapterMethod · 0.95
setErrorStateMethod · 0.95
handleThrowableMethod · 0.95
getErrorStateMethod · 0.95
isAsyncMethod · 0.95
dispatchEndRequestMethod · 0.95
getWriteListenerMethod · 0.80
asyncOperationMethod · 0.80
getReadListenerMethod · 0.80

Tested by

no test coverage detected