tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1576548 - in /tomcat/trunk/java/org/apache: coyote/http11/upgrade/Nio2ServletInputStream.java coyote/http11/upgrade/Nio2ServletOutputStream.java tomcat/util/net/Nio2Channel.java
Date Wed, 12 Mar 2014 00:06:10 GMT
Author: remm
Date: Wed Mar 12 00:06:10 2014
New Revision: 1576548

URL: http://svn.apache.org/r1576548
Log:
- Harmonize with the NIO1 connector for upgrade close.
- Actually understand where the (cosmetic) async close traces were coming from.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java
    tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java
    tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java?rev=1576548&r1=1576547&r2=1576548&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletInputStream.java Wed Mar
12 00:06:10 2014
@@ -71,6 +71,10 @@ public class Nio2ServletInputStream exte
             public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment)
{
                 attachment.setError(true);
                 readPending = false;
+                if (exc instanceof AsynchronousCloseException) {
+                    // If already closed, don't call onError and close again 
+                    return;
+                }
                 onError(exc);
                 try {
                     close();
@@ -189,11 +193,7 @@ public class Nio2ServletInputStream exte
 
     @Override
     protected void doClose() throws IOException {
-        try {
-            channel.close();
-        } catch (AsynchronousCloseException e) {
-            // Ignore
-        }
+        channel.close();
     }
 
     private int fillReadBuffer(boolean block) throws IOException {

Modified: tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java?rev=1576548&r1=1576547&r2=1576548&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/upgrade/Nio2ServletOutputStream.java Wed Mar
12 00:06:10 2014
@@ -63,6 +63,10 @@ public class Nio2ServletOutputStream ext
             public void failed(Throwable exc, SocketWrapper<Nio2Channel> attachment)
{
                 attachment.setError(true);
                 writePending = false;
+                if (exc instanceof AsynchronousCloseException) {
+                    // If already closed, don't call onError and close again 
+                    return;
+                }
                 onError(exc);
                 try {
                     close();
@@ -157,10 +161,6 @@ public class Nio2ServletOutputStream ext
 
     @Override
     protected void doClose() throws IOException {
-        try {
-            channel.close();
-        } catch (AsynchronousCloseException e) {
-            // Ignore
-        }
+        channel.close(true);
     }
 }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java?rev=1576548&r1=1576547&r2=1576548&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java Wed Mar 12 00:06:10 2014
@@ -84,12 +84,15 @@ public class Nio2Channel implements Asyn
      */
     @Override
     public void close() throws IOException {
-        getIOChannel().close();
+        sc.close();
     }
 
     public void close(boolean force) throws IOException {
-        if (isOpen() || force ) close();
+        if (isOpen() || force) {
+            close();
+        }
     }
+
     /**
      * Tells whether or not this channel is open.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message