@Override
    public Runnable createRunnableHandler(final HttpInboundConnection inboundConnection) {
        final Dispatcher reqDispatcher = dispatcher;

        String uri = inboundConnection.getRequest().getURI();

        for (ServletHandler handler : registry.getServlets()) {
            if (handler.matches(uri)) {
                final ServletHandler myHandler = handler;

                return new Runnable() {
                    @Override
                    public void run() {
                        final RequestMessage request = new RequestMessage(inboundConnection, SingletonSessionManager.instance);
                        final ResponseMessage response = new ResponseMessage(inboundConnection, request);

                        Exception error = null;
                        try {
                            request.setServletContext(myHandler.getServlet().getServletConfig().getServletContext());
                            request.setServletPath(myHandler.getAlias());
                            reqDispatcher.dispatch(request, response);
                        } catch (Exception e) {
                            error = e;

                            if (!response.isCommitted()) {
                                try {
                                    response.sendError(500);
                                } catch (Throwable t) {
                                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                        Tr.debug(tc, "Unable to send 500 error response", t);
                                    }
                                }
                            }
                        } finally {
                            response.finish();
                            inboundConnection.finish(error);
                        }
                    }
                };
            }
        }

        return null;
    }
@ Override public Runnable createRunnableHandler ( final HttpInboundConnection inboundConnection ) { final Dispatcher reqDispatcher = dispatcher ; String uri = inboundConnection . getRequest ( ) . getURI ( ) ; for ( ServletHandler handler : registry . getServlets ( ) ) { if ( handler . matches ( uri ) ) { final ServletHandler myHandler = handler ; return new Runnable ( ) { @ Override public void run ( ) { final RequestMessage request = new RequestMessage ( inboundConnection , SingletonSessionManager . instance ) ; final ResponseMessage response = new ResponseMessage ( inboundConnection , request ) ; Exception error = null ; try { request . setServletContext ( myHandler . getServlet ( ) . getServletConfig ( ) . getServletContext ( ) ) ; request . setServletPath ( myHandler . getAlias ( ) ) ; reqDispatcher . dispatch ( request , response ) ; } catch ( Exception e ) { error = e ; if ( ! response . isCommitted ( ) ) { try { response . sendError ( 500 ) ; } catch ( Throwable t ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Unable to send 500 error response" , t ) ; } } } } finally { response . finish ( ) ; inboundConnection . finish ( error ) ; } } } ; } } return null ; }
{@inheritDoc}