On Fri, 2017-05-05 at 16:55 -0700, Gary Gregory wrote:
> In our method
> _org.apache.http.nio.protocol.HttpAsyncService.exception(NHttpServerC
> onnection,
> Exception)_ the log() method does not always get called:
>
> @Override
> public void exception(
> final NHttpServerConnection conn, final Exception cause)
> {
> final State state = getState(conn);
> if (state == null) {
> shutdownConnection(conn);
> log(cause);
> return;
> }
> state.setTerminated();
> closeHandlers(state, cause);
> final Cancellable cancellable = state.getCancellable();
> if (cancellable != null) {
> cancellable.cancel();
> }
> final Queue<PipelineEntry> pipeline = state.getPipeline();
> if (!pipeline.isEmpty()
> || conn.isResponseSubmitted()
> ||
> state.getResponseState().compareTo(MessageState.INIT) >
> 0) {
> // There is not much that we can do if a response
> // has already been submitted or pipelining is being
> used.
> shutdownConnection(conn);
> } else {
> try {
> final Incoming incoming = state.getIncoming();
> final HttpRequest request = incoming != null ?
> incoming.getRequest() : null;
> final HttpContext context = incoming != null ?
> incoming.getContext() : new BasicHttpContext();
> final HttpAsyncResponseProducer responseProducer =
> handleException(cause, context);
> final HttpResponse response =
> responseProducer.generateResponse();
> final Outgoing outgoing = new Outgoing(request,
> response,
> responseProducer, context);
> state.setResponseState(MessageState.INIT);
> state.setOutgoing(outgoing);
> commitFinalResponse(conn, state);
> /////////////////////////////////////////////////////
> /////
> /////////////////////////////////////////////////////
> /////
> // log() has not been called by the time we get here
> /////////////////////////////////////////////////////
> /////
> /////////////////////////////////////////////////////
> /////
> } catch (final Exception ex) {
> shutdownConnection(conn);
> closeHandlers(state);
> if (ex instanceof RuntimeException) {
> throw (RuntimeException) ex;
> } else {
> log(ex);
> }
> }
> }
> }
>
> So I propose we move the call to log from:
>
> if (state == null) {
> shutdownConnection(conn);
> log(cause);
> return;
> }
>
> To the first line of the method:
>
> @Override
> public void exception(
> final NHttpServerConnection conn, final Exception cause)
> {
> log(cause);
> final State state = getState(conn);
> if (state == null) {
> shutdownConnection(conn);
> return;
> }
>
> Thoughts?
>
> Gary
>
Gary
It would make things much easier if you forked HttpCore at GitHub,
patched your private fork, gave us a reference to the diff set in your
repository and asked for a review.
This should be the standard work-flow anyway once we migrate to Git.
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]