Return-Path: Delivered-To: apmail-jakarta-httpcomponents-commits-archive@www.apache.org Received: (qmail 83694 invoked from network); 4 Jun 2007 11:11:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jun 2007 11:11:48 -0000 Received: (qmail 22188 invoked by uid 500); 4 Jun 2007 11:11:52 -0000 Delivered-To: apmail-jakarta-httpcomponents-commits-archive@jakarta.apache.org Received: (qmail 22173 invoked by uid 500); 4 Jun 2007 11:11:52 -0000 Mailing-List: contact httpcomponents-commits-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: httpcomponents-dev@jakarta.apache.org Delivered-To: mailing list httpcomponents-commits@jakarta.apache.org Received: (qmail 22159 invoked by uid 99); 4 Jun 2007 11:11:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jun 2007 04:11:52 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jun 2007 04:11:47 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6A82B1A981A; Mon, 4 Jun 2007 04:11:27 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r544120 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol: BufferingHttpServiceHandler.java ThrottlingHttpServiceHandler.java Date: Mon, 04 Jun 2007 11:11:27 -0000 To: httpcomponents-commits@jakarta.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070604111127.6A82B1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Mon Jun 4 04:11:25 2007 New Revision: 544120 URL: http://svn.apache.org/viewvc?view=rev&rev=544120 Log: Cleaned up HTTP protocol exception handling Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java?view=diff&rev=544120&r1=544119&r2=544120 ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java (original) +++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java Mon Jun 4 04:11:25 2007 @@ -230,6 +230,7 @@ HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR, context); HttpParamsLinker.link(response, this.params); handleException(httpex, response); + response.setEntity(null); sendResponse(conn, response); } catch (IOException ex) { Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?view=diff&rev=544120&r1=544119&r2=544120 ============================================================================== --- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java (original) +++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Mon Jun 4 04:11:25 2007 @@ -172,12 +172,41 @@ } } - public void exception(final NHttpServerConnection conn, final HttpException ex) { - shutdownConnection(conn); + public void exception(final NHttpServerConnection conn, final HttpException httpex) { + HttpContext context = conn.getContext(); - if (this.eventListener != null) { - this.eventListener.fatalProtocolException(ex, conn); + ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE); + + try { + + HttpResponse response = this.responseFactory.newHttpResponse( + HttpVersion.HTTP_1_0, + HttpStatus.SC_INTERNAL_SERVER_ERROR, + context); + HttpParamsLinker.link(response, this.params); + handleException(httpex, response); + response.setEntity(null); + + this.httpProcessor.process(response, context); + + synchronized (connState) { + connState.setResponse(response); + // Response is ready to be committed + conn.requestOutput(); + } + + } catch (IOException ex) { + shutdownConnection(conn); + if (eventListener != null) { + eventListener.fatalIOException(ex, conn); + } + } catch (HttpException ex) { + shutdownConnection(conn); + if (eventListener != null) { + eventListener.fatalProtocolException(ex, conn); + } } + } public void exception(final NHttpServerConnection conn, final IOException ex) { @@ -278,11 +307,14 @@ HttpContext context = conn.getContext(); ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE); - HttpResponse response = connState.getResponse(); - if (connState.getOutputState() == ServerConnState.READY - && response != null - && !conn.isResponseSubmitted()) { - try { + + try { + + HttpResponse response = connState.getResponse(); + if (connState.getOutputState() == ServerConnState.READY + && response != null + && !conn.isResponseSubmitted()) { + conn.submitResponse(response); synchronized (connState) { @@ -305,17 +337,17 @@ connState.notifyAll(); } - - } catch (IOException ex) { - shutdownConnection(conn); - if (eventListener != null) { - eventListener.fatalIOException(ex, conn); - } - } catch (HttpException ex) { - shutdownConnection(conn); - if (eventListener != null) { - eventListener.fatalProtocolException(ex, conn); - } + } + + } catch (IOException ex) { + shutdownConnection(conn); + if (eventListener != null) { + eventListener.fatalIOException(ex, conn); + } + } catch (HttpException ex) { + shutdownConnection(conn); + if (eventListener != null) { + eventListener.fatalProtocolException(ex, conn); } } } @@ -504,7 +536,7 @@ } catch (HttpException ex) { response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR, context); - HttpParamsLinker.link(request, this.params); + HttpParamsLinker.link(response, this.params); handleException(ex, response); } }