Author: markt
Date: Thu Sep 17 08:56:20 2015
New Revision: 1703534
URL: http://svn.apache.org/r1703534
Log:
Code review / refactoring in light of
https://bz.apache.org/bugzilla/show_bug.cgi?id=58390
error is only used by NIO2 so move it to Nio2SocketWrapper
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java?rev=1703534&r1=1703533&r2=1703534&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Thu Sep 17
08:56:20 2015
@@ -577,6 +577,7 @@ public class Nio2Endpoint extends Abstra
private final Semaphore writePending = new Semaphore(1);
private boolean writeInterest = false; // Guarded by
writeCompletionHandler
private boolean writeNotify = false;
+ private volatile IOException error = null;
private CompletionHandler<Integer, SocketWrapperBase<Nio2Channel>>
awaitBytesHandler
= new CompletionHandler<Integer,
SocketWrapperBase<Nio2Channel>>() {
@@ -847,6 +848,9 @@ public class Nio2Endpoint extends Abstra
public void setSendfileData(SendfileData sf) { this.sendfileData = sf;
}
public SendfileData getSendfileData() { return this.sendfileData; }
+ public IOException getError() { return error; }
+ public void setError(IOException error) { this.error = error; }
+
@Override
public boolean isReadyForRead() throws IOException {
@@ -1250,6 +1254,11 @@ public class Nio2Endpoint extends Abstra
@Override
protected void flushBlocking() throws IOException {
+ if (getError() != null) {
+ throw getError();
+ }
+
+
// Before doing a blocking flush, make sure that any pending non
// blocking write has completed.
try {
@@ -1266,7 +1275,11 @@ public class Nio2Endpoint extends Abstra
}
@Override
- protected boolean flushNonBlocking() {
+ protected boolean flushNonBlocking() throws IOException {
+ if (getError() != null) {
+ throw getError();
+ }
+
return flushNonBlocking(false);
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1703534&r1=1703533&r2=1703534&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Thu Sep 17
08:56:20 2015
@@ -1071,8 +1071,6 @@ public class NioEndpoint extends Abstrac
NioSocketWrapper ka = (NioSocketWrapper)
key.attachment();
if ( ka == null ) {
cancelledKey(key); //we don't support any keys
without attachments
- } else if ( ka.getError() != null) {
- cancelledKey(key);//TODO this is not yet being used
} else if ((ka.interestOps()&SelectionKey.OP_READ) ==
SelectionKey.OP_READ ||
(ka.interestOps()&SelectionKey.OP_WRITE) ==
SelectionKey.OP_WRITE) {
if (close) {
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java?rev=1703534&r1=1703533&r2=1703534&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketWrapperBase.java Thu Sep
17 08:56:20 2015
@@ -46,7 +46,6 @@ public abstract class SocketWrapperBase<
private volatile long readTimeout = -1;
private volatile long writeTimeout = -1;
- private IOException error = null;
private volatile int keepAliveLeft = 100;
private volatile boolean async = false;
private boolean keptAlive = false;
@@ -199,8 +198,6 @@ public abstract class SocketWrapperBase<
}
- public IOException getError() { return error; }
- public void setError(IOException error) { this.error = error; }
public void setKeepAliveLeft(int keepAliveLeft) { this.keepAliveLeft =
keepAliveLeft;}
public int decrementKeepAlive() { return (--keepAliveLeft);}
public boolean isKeptAlive() {return keptAlive;}
@@ -484,10 +481,6 @@ public abstract class SocketWrapperBase<
return false;
}
- if (getError() != null) {
- throw getError();
- }
-
boolean result = false;
if (block) {
// A blocking flush will always empty the buffer.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]