You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2008/08/29 18:11:12 UTC

svn commit: r690311 - in /httpcomponents/httpcore/trunk/module-nio/src: main/java/org/apache/http/nio/protocol/ test/java/org/apache/http/nio/protocol/

Author: olegk
Date: Fri Aug 29 09:11:12 2008
New Revision: 690311

URL: http://svn.apache.org/viewvc?rev=690311&view=rev
Log:
Changed throttling protocol handlers to make use of Shared*Buffer#close() method

Modified:
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
    httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java?rev=690311&r1=690310&r2=690311&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpClientHandler.java Fri Aug 29 09:11:12 2008
@@ -138,7 +138,7 @@
         
         if (connState != null) {
             synchronized (connState) {
-                connState.shutdown();
+                connState.close();
                 connState.notifyAll();
             }
         }
@@ -636,6 +636,19 @@
             this.workerRunning = b;
         }
 
+        public void close() {
+            try {
+                this.inbuffer.close();
+            } catch (IOException ignore) {
+            }
+            try {
+                this.outbuffer.close();
+            } catch (IOException ignore) {
+            }
+            this.inputState = SHUTDOWN;
+            this.outputState = SHUTDOWN;
+        }
+
         public void shutdown() {
             this.inbuffer.shutdown();
             this.outbuffer.shutdown();

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java?rev=690311&r1=690310&r2=690311&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/protocol/ThrottlingHttpServiceHandler.java Fri Aug 29 09:11:12 2008
@@ -155,7 +155,7 @@
         
         if (connState != null) {
             synchronized (connState) {
-                connState.shutdown();
+                connState.close();
                 connState.notifyAll();
             }
         }
@@ -687,6 +687,19 @@
             this.expectationFailure = b;
         }
 
+        public void close() {
+            try {
+                this.inbuffer.close();
+            } catch (IOException ignore) {
+            }
+            try {
+                this.outbuffer.close();
+            } catch (IOException ignore) {
+            }
+            this.inputState = SHUTDOWN;
+            this.outputState = SHUTDOWN;
+        }
+
         public void shutdown() {
             this.inbuffer.shutdown();
             this.outbuffer.shutdown();

Modified: httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java?rev=690311&r1=690310&r2=690311&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/module-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java Fri Aug 29 09:11:12 2008
@@ -680,8 +680,6 @@
             
         };
         
-        // additional expectation: server-side processing ends with an exception.
-        final Exception handlerException = new Exception();
         HttpRequestHandler requestHandler = new HttpRequestHandler() {
             public void handle(
                     HttpRequest request,
@@ -691,7 +689,6 @@
                     ((HttpEntityEnclosingRequest) request).getEntity().getContent().read();
                     response.setStatusCode(HttpStatus.SC_OK);
                 } catch (Exception e){
-                    handlerException.initCause(e);
                 }
             }
         };
@@ -765,10 +762,6 @@
             }
         }
         
-        // ensure server-side processing was aborted
-        assertNotNull(handlerException.getCause());
-        assertEquals(InterruptedIOException.class, handlerException.getCause().getClass());
-        
         this.execService.shutdown();
         this.execService.awaitTermination(10, TimeUnit.SECONDS);