Author: remm
Date: Fri Apr  4 10:10:28 2014
New Revision: 1584593

URL: http://svn.apache.org/r1584593
Log:
Code cleanups and i18n in NIO2.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java
    tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java
    tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
    tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Nio2Processor.java Fri Apr 
 4 10:10:28 2014
@@ -455,7 +455,7 @@ public class Http11Nio2Processor extends
                                 .getSslImplementation().getSSLSupport(
                                         engine.getSession());
                     } catch (IOException ioe) {
-                        
log.warn(sm.getString("http11processor.socket.sslreneg",ioe));
+                        
log.warn(sm.getString("http11processor.socket.sslreneg"), ioe);
                     }
                 }
 

Modified: 
tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java Fri 
Apr  4 10:10:28 2014
@@ -755,11 +755,11 @@ public class InternalNio2InputBuffer ext
                 synchronized (completionHandler) {
                     if (nBytes.intValue() < 0) {
                         failed(new 
EOFException(sm.getString("iib.eof.error")), attachment);
-                        return;
-                    }
-                    readPending = false;
-                    if (!Nio2Endpoint.isInline()) {
-                        notify = true;
+                    } else {
+                        readPending = false;
+                        if (!Nio2Endpoint.isInline()) {
+                            notify = true;
+                        }
                     }
                 }
                 if (notify) {

Modified: 
tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2OutputBuffer.java 
Fri Apr  4 10:10:28 2014
@@ -118,7 +118,6 @@ public class InternalNio2OutputBuffer ex
                 synchronized (completionHandler) {
                     if (nBytes.intValue() < 0) {
                         failed(new 
EOFException(sm.getString("iob.failedwrite")), attachment);
-                        return;
                     } else if (bufferedWrites.size() > 0) {
                         // Continue writing data using a gathering write
                         ArrayList<ByteBuffer> arrayList = new ArrayList<>();
@@ -172,7 +171,6 @@ public class InternalNio2OutputBuffer ex
                 synchronized (completionHandler) {
                     if (nBytes.longValue() < 0) {
                         failed(new 
EOFException(sm.getString("iob.failedwrite")), attachment);
-                        return;
                     } else if (bufferedWrites.size() > 0 || 
arrayHasData(attachment)) {
                         // Continue writing data
                         ArrayList<ByteBuffer> arrayList = new ArrayList<>();

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=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Channel.java Fri Apr  4 
10:10:28 2014
@@ -39,13 +39,9 @@ public class Nio2Channel implements Asyn
 
     protected AsynchronousSocketChannel sc = null;
     protected SocketWrapper<Nio2Channel> socket = null;
-
     protected ApplicationBufferHandler bufHandler;
 
-    protected boolean sendFile = false;
-
-    public Nio2Channel(AsynchronousSocketChannel channel, 
ApplicationBufferHandler bufHandler) {
-        this.sc = channel;
+    public Nio2Channel(ApplicationBufferHandler bufHandler) {
         this.bufHandler = bufHandler;
     }
 
@@ -54,15 +50,12 @@ public class Nio2Channel implements Asyn
      *
      * @throws IOException If a problem was encountered resetting the channel
      */
-    public void reset() throws IOException {
+    public void reset(AsynchronousSocketChannel channel, 
SocketWrapper<Nio2Channel> socket)
+            throws IOException {
+        this.sc = channel;
+        this.socket = socket;
         bufHandler.getReadBuffer().clear();
         bufHandler.getWriteBuffer().clear();
-        sendFile = false;
-        socket = null;
-    }
-
-    void setSocket(SocketWrapper<Nio2Channel> socket) {
-        this.socket = socket;
     }
 
     public SocketWrapper<Nio2Channel> getSocket() {
@@ -130,23 +123,11 @@ public class Nio2Channel implements Asyn
         return 0;
     }
 
-    public void setIOChannel(AsynchronousSocketChannel IOChannel) {
-        this.sc = IOChannel;
-    }
-
     @Override
     public String toString() {
         return super.toString()+":"+this.sc.toString();
     }
 
-    public boolean isSendFile() {
-        return sendFile;
-    }
-
-    public void setSendFile(boolean s) {
-        this.sendFile = s;
-    }
-
     @Override
     public Future<Integer> read(ByteBuffer dst) {
         return sc.read(dst);

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=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/Nio2Endpoint.java Fri Apr  4 
10:10:28 2014
@@ -415,9 +415,6 @@ public class Nio2Endpoint extends Abstra
      */
     @Override
     public void unbind() throws Exception {
-        if (log.isDebugEnabled()) {
-            log.debug("Destroy initiated for "+new 
InetSocketAddress(getAddress(),getPort()));
-        }
         if (running) {
             stop();
         }
@@ -428,9 +425,6 @@ public class Nio2Endpoint extends Abstra
         // Unlike other connectors, the thread pool is tied to the server 
socket
         shutdownExecutor();
         releaseCaches();
-        if (log.isDebugEnabled()) {
-            log.debug("Destroy completed for "+new 
InetSocketAddress(getAddress(),getPort()));
-        }
     }
 
 
@@ -505,34 +499,32 @@ public class Nio2Endpoint extends Abstra
                 if (sslContext != null) {
                     SSLEngine engine = createSSLEngine();
                     int appBufferSize = 
engine.getSession().getApplicationBufferSize();
-                    NioBufferHandler bufhandler = new 
NioBufferHandler(Math.max(appBufferSize, socketProperties.getAppReadBufSize()),
+                    NioBufferHandler bufhandler = new NioBufferHandler(
+                            Math.max(appBufferSize, 
socketProperties.getAppReadBufSize()),
                             Math.max(appBufferSize, 
socketProperties.getAppWriteBufSize()),
                             socketProperties.getDirectBuffer());
-                    channel = new SecureNio2Channel(socket, engine, 
bufhandler, this);
+                    channel = new SecureNio2Channel(engine, bufhandler, this);
                 } else {
-                    // normal tcp setup
-                    NioBufferHandler bufhandler = new 
NioBufferHandler(socketProperties.getAppReadBufSize(),
-                                                                       
socketProperties.getAppWriteBufSize(),
-                                                                       
socketProperties.getDirectBuffer());
-
-                    channel = new Nio2Channel(socket, bufhandler);
+                    NioBufferHandler bufhandler = new NioBufferHandler(
+                            socketProperties.getAppReadBufSize(),
+                            socketProperties.getAppWriteBufSize(),
+                            socketProperties.getDirectBuffer());
+                    channel = new Nio2Channel(bufhandler);
                 }
             } else {
-                channel.setIOChannel(socket);
-                if (channel instanceof SecureNio2Channel) {
+                if (sslContext != null) {
                     SSLEngine engine = createSSLEngine();
                     ((SecureNio2Channel) channel).setSSLEngine(engine);
                 }
-                channel.reset();
             }
             Nio2SocketWrapper socketWrapper = (useCaches) ? 
socketWrapperCache.pop() : null;
             if (socketWrapper == null) {
                 socketWrapper = new Nio2SocketWrapper(channel);
             }
+            channel.reset(socket, socketWrapper);
             socketWrapper.reset(channel, getSocketProperties().getSoTimeout());
             
socketWrapper.setKeepAliveLeft(Nio2Endpoint.this.getMaxKeepAliveRequests());
             socketWrapper.setSecure(isSSLEnabled());
-            channel.setSocket(socketWrapper);
             if (sslContext != null) {
                 // Use the regular processing, as the first handshake needs to 
be done there
                 processSocket(socketWrapper, SocketStatus.OPEN_READ, true);
@@ -983,7 +975,6 @@ public class Nio2Endpoint extends Abstra
         }
 
         if (nr >= 0) {
-            socket.getSocket().setSendFile(true);
             buffer.flip();
             socket.getSocket().write(buffer, data, new 
CompletionHandler<Integer, SendfileData>() {
 
@@ -1010,7 +1001,6 @@ public class Nio2Endpoint extends Abstra
                             // Ignore
                         }
                         if (attachment.keepAlive) {
-                            socket.getSocket().setSendFile(false);
                             awaitBytes(socket);
                         } else {
                             closeSocket(socket, SocketStatus.DISCONNECT);
@@ -1036,7 +1026,10 @@ public class Nio2Endpoint extends Abstra
                                 ok = false;
                             }
                         } catch (Throwable th) {
-                            if ( log.isDebugEnabled() ) log.debug("Unable to 
complete sendfile request:", th);
+                            ExceptionUtils.handleThrowable(th);
+                            if (log.isDebugEnabled()) {
+                                
log.debug(sm.getString("endpoint.sendfile.error"), th);
+                            }
                             ok = false;
                         }
                     }
@@ -1132,7 +1125,9 @@ public class Nio2Endpoint extends Abstra
                     }
                 } catch (IOException x) {
                     handshake = -1;
-                    if (log.isDebugEnabled()) log.debug("Error during SSL 
handshake",x);
+                    if (log.isDebugEnabled()) {
+                        log.debug(sm.getString("endpoint.err.handshake"), x);
+                    }
                 }
                 if (handshake == 0) {
                     SocketState state = SocketState.OPEN;
@@ -1144,17 +1139,13 @@ public class Nio2Endpoint extends Abstra
                     }
                     if (state == SocketState.CLOSED) {
                         // Close socket and pool
-                        try {
-                            socket.setComet(false);
-                            closeSocket(socket, SocketStatus.ERROR);
-                            if (useCaches && running && !paused) {
-                                nioChannels.push(socket.getSocket());
-                            }
-                            if (useCaches && running && !paused && socket != 
null) {
-                                socketWrapperCache.push((Nio2SocketWrapper) 
socket);
-                            }
-                        } catch (Exception x) {
-                            log.error("",x);
+                        socket.setComet(false);
+                        closeSocket(socket, SocketStatus.ERROR);
+                        if (useCaches && running && !paused) {
+                            nioChannels.push(socket.getSocket());
+                        }
+                        if (useCaches && running && !paused && socket != null) 
{
+                            socketWrapperCache.push((Nio2SocketWrapper) 
socket);
                         }
                     } else if (state == SocketState.UPGRADING) {
                         socket.setKeptAlive(true);
@@ -1191,7 +1182,7 @@ public class Nio2Endpoint extends Abstra
             } catch (VirtualMachineError vme) {
                 ExceptionUtils.handleThrowable(vme);
             } catch (Throwable t) {
-                log.error("", t);
+                log.error(sm.getString("endpoint.processing.fail"), t);
                 if (socket != null) {
                     closeSocket(socket, SocketStatus.ERROR);
                 }

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Fri Apr 
 4 10:10:28 2014
@@ -34,31 +34,35 @@ import javax.net.ssl.SSLEngineResult.Han
 import javax.net.ssl.SSLEngineResult.Status;
 import javax.net.ssl.SSLException;
 
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Implementation of a secure socket channel for NIO2.
  */
 public class SecureNio2Channel extends Nio2Channel  {
 
+    protected static final StringManager sm = 
StringManager.getManager("org.apache.tomcat.util.net.res");
+
     protected ByteBuffer netInBuffer;
     protected ByteBuffer netOutBuffer;
 
     protected SSLEngine sslEngine;
     protected final Nio2Endpoint endpoint;
 
-    protected boolean handshakeComplete = false;
+    protected boolean handshakeComplete;
     protected HandshakeStatus handshakeStatus; //gets set by handshake
 
-    protected boolean closed = false;
-    protected boolean closing = false;
-    protected volatile boolean readPending = false;
-    protected volatile boolean writePending = false;
+    protected boolean closed;
+    protected boolean closing;
+    protected volatile boolean readPending;
+    protected volatile boolean writePending;
 
     private CompletionHandler<Integer, SocketWrapper<Nio2Channel>> 
handshakeReadCompletionHandler;
     private CompletionHandler<Integer, SocketWrapper<Nio2Channel>> 
handshakeWriteCompletionHandler;
 
-    public SecureNio2Channel(AsynchronousSocketChannel channel, SSLEngine 
engine,
-            ApplicationBufferHandler bufHandler, Nio2Endpoint endpoint0) 
throws IOException {
-        super(channel, bufHandler);
+    public SecureNio2Channel(SSLEngine engine, ApplicationBufferHandler 
bufHandler,
+            Nio2Endpoint endpoint0) throws IOException {
+        super(bufHandler);
         sslEngine = engine;
         endpoint = endpoint0;
         int netBufSize = sslEngine.getSession().getPacketBufferSize();
@@ -97,7 +101,6 @@ public class SecureNio2Channel extends N
                 endpoint.closeSocket(attachment, SocketStatus.ERROR);
             }
         };
-        reset();
     }
 
     public void setSSLEngine(SSLEngine engine) {
@@ -105,8 +108,9 @@ public class SecureNio2Channel extends N
     }
 
     @Override
-    public void reset() throws IOException {
-        super.reset();
+    public void reset(AsynchronousSocketChannel channel, 
SocketWrapper<Nio2Channel> socket)
+            throws IOException {
+        super.reset(channel, socket);
         netOutBuffer.position(0);
         netOutBuffer.limit(0);
         netInBuffer.position(0);
@@ -210,7 +214,7 @@ public class SecureNio2Channel extends N
             switch (handshakeStatus) {
                 case NOT_HANDSHAKING: {
                     //should never happen
-                    throw new IOException("NOT_HANDSHAKING during handshake");
+                    throw new 
IOException(sm.getString("channel.nio.ssl.notHandshaking"));
                 }
                 case FINISHED: {
                     //we are complete if we have delivered the last package
@@ -225,7 +229,7 @@ public class SecureNio2Channel extends N
                             try {
                                 
sc.write(netOutBuffer).get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS);
                             } catch (InterruptedException | ExecutionException 
| TimeoutException e) {
-                                throw new IOException("Handshake error");
+                                throw new 
IOException(sm.getString("channel.nio.ssl.handhakeError"));
                             }
                         }
                         return 1;
@@ -239,7 +243,7 @@ public class SecureNio2Channel extends N
                             handshakeStatus = tasks();
                     } else {
                         //wrap should always work with our buffers
-                        throw new IOException("Unexpected status:" + 
handshake.getStatus() + " during handshake WRAP.");
+                        throw new 
IOException(sm.getString("channel.nio.ssl.unexpectedStatusDuringWrap", 
handshake.getStatus()));
                     }
                     if (handshakeStatus != HandshakeStatus.NEED_UNWRAP || 
netOutBuffer.remaining() > 0) {
                         //should actually return OP_READ if we have NEED_UNWRAP
@@ -249,7 +253,7 @@ public class SecureNio2Channel extends N
                             try {
                                 
sc.write(netOutBuffer).get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS);
                             } catch (InterruptedException | ExecutionException 
| TimeoutException e) {
-                                throw new IOException("Handshake error");
+                                throw new 
IOException(sm.getString("channel.nio.ssl.handhakeError"));
                             }
                         }
                         return 1;
@@ -272,12 +276,12 @@ public class SecureNio2Channel extends N
                             try {
                                 
sc.read(netInBuffer).get(endpoint.getSoTimeout(), TimeUnit.MILLISECONDS);
                             } catch (InterruptedException | ExecutionException 
| TimeoutException e) {
-                                throw new IOException("Handshake error");
+                                throw new 
IOException(sm.getString("channel.nio.ssl.handhakeError"));
                             }
                         }
                         return 1;
                     } else {
-                        throw new IOException("Invalid handshake 
status:"+handshakeStatus+" during handshake UNWRAP.");
+                        throw new 
IOException(sm.getString("channel.nio.ssl.unexpectedStatusDuringUnwrap", 
handshakeStatus));
                     }
                     break;
                 }
@@ -285,7 +289,7 @@ public class SecureNio2Channel extends N
                     handshakeStatus = tasks();
                     break;
                 }
-                default: throw new IllegalStateException("Invalid handshake 
status:"+handshakeStatus);
+                default: throw new 
IllegalStateException(sm.getString("channel.nio.ssl.invalidStatus", 
handshakeStatus));
             }
         }
         //return 0 if we are complete, otherwise recurse to process the task
@@ -301,17 +305,31 @@ public class SecureNio2Channel extends N
      */
     public void rehandshake() throws IOException {
         //validate the network buffers are empty
-        if (netInBuffer.position() > 0 && 
netInBuffer.position()<netInBuffer.limit()) throw new IOException("Network 
input buffer still contains data. Handshake will fail.");
-        if (netOutBuffer.position() > 0 && 
netOutBuffer.position()<netOutBuffer.limit()) throw new IOException("Network 
output buffer still contains data. Handshake will fail.");
-        if (getBufHandler().getReadBuffer().position()>0 && 
getBufHandler().getReadBuffer().position()<getBufHandler().getReadBuffer().limit())
 throw new IOException("Application input buffer still contains data. Data 
would have been lost.");
-        if (getBufHandler().getWriteBuffer().position()>0 && 
getBufHandler().getWriteBuffer().position()<getBufHandler().getWriteBuffer().limit())
 throw new IOException("Application output buffer still contains data. Data 
would have been lost.");
-        reset();
+        if (netInBuffer.position() > 0 && netInBuffer.position() < 
netInBuffer.limit()) throw new 
IOException(sm.getString("channel.nio.ssl.netInputNotEmpty"));
+        if (netOutBuffer.position() > 0 && netOutBuffer.position() < 
netOutBuffer.limit()) throw new 
IOException(sm.getString("channel.nio.ssl.netOutputNotEmpty"));
+        ByteBuffer readBuffer = getBufHandler().getReadBuffer();
+        ByteBuffer writeBuffer = getBufHandler().getWriteBuffer();
+        if (readBuffer.position() > 0 && readBuffer.position() < 
readBuffer.limit()) throw new 
IOException(sm.getString("channel.nio.ssl.appInputNotEmpty"));
+        if (writeBuffer.position() > 0 && writeBuffer.position() < 
writeBuffer.limit()) throw new 
IOException(sm.getString("channel.nio.ssl.appOutputNotEmpty"));
+
+        netOutBuffer.position(0);
+        netOutBuffer.limit(0);
+        netInBuffer.position(0);
+        netInBuffer.limit(0);
+        readBuffer.clear();
+        writeBuffer.clear();
+
+        handshakeComplete = false;
+        //initiate handshake
+        sslEngine.beginHandshake();
+        handshakeStatus = sslEngine.getHandshakeStatus();
+
         boolean handshaking = true;
         try {
             while (handshaking) {
                 int hsStatus = handshakeInternal(false);
                 switch (hsStatus) {
-                    case -1 : throw new EOFException("EOF during handshake.");
+                    case -1 : throw new 
EOFException(sm.getString("channel.nio.ssl.eofDuringHandshake"));
                     case  0 : handshaking = false; break;
                     default : // Some blocking IO occurred, so iterate
                 }
@@ -325,7 +343,6 @@ public class SecureNio2Channel extends N
     }
 
 
-
     /**
      * Executes all the tasks needed on the same thread.
      * @return HandshakeStatus
@@ -410,12 +427,12 @@ public class SecureNio2Channel extends N
 
         try {
             if (!flush().get(endpoint.getSoTimeout(), 
TimeUnit.MILLISECONDS).booleanValue()) {
-                throw new IOException("Remaining data in the network buffer, 
can't send SSL close message, force a close with close(true) instead");
+                throw new 
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"));
             }
         } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
-            throw new IOException("Remaining data in the network buffer, can't 
send SSL close message, force a close with close(true) instead", e);
+            throw new 
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"), e);
         } catch (WritePendingException e) {
-            throw new IOException("Pending write, so remaining data in the 
network buffer, can't send SSL close message, force a close with close(true) 
instead", e);
+            throw new 
IOException(sm.getString("channel.nio.ssl.pendingWriteDuringClose"), e);
         }
         //prep the buffer for the close message
         netOutBuffer.clear();
@@ -423,19 +440,19 @@ public class SecureNio2Channel extends N
         SSLEngineResult handshake = sslEngine.wrap(getEmptyBuf(), 
netOutBuffer);
         //we should be in a close state
         if (handshake.getStatus() != SSLEngineResult.Status.CLOSED) {
-            throw new IOException("Invalid close state, will not send network 
data.");
+            throw new 
IOException(sm.getString("channel.nio.ssl.invalidCloseState"));
         }
         //prepare the buffer for writing
         netOutBuffer.flip();
         //if there is data to be written
         try {
             if (!flush().get(endpoint.getSoTimeout(), 
TimeUnit.MILLISECONDS).booleanValue()) {
-                throw new IOException("Remaining data in the network buffer, 
can't send SSL close message, force a close with close(true) instead");
+                throw new 
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"));
             }
         } catch (InterruptedException | ExecutionException | TimeoutException 
e) {
-            throw new IOException("Remaining data in the network buffer, can't 
send SSL close message, force a close with close(true) instead", e);
+            throw new 
IOException(sm.getString("channel.nio.ssl.remainingDataDuringClose"), e);
         } catch (WritePendingException e) {
-            throw new IOException("Pending write, so remaining data in the 
network buffer, can't send SSL close message, force a close with close(true) 
instead", e);
+            throw new 
IOException(sm.getString("channel.nio.ssl.pendingWriteDuringClose"), e);
         }
 
         //is the channel closed?
@@ -533,7 +550,7 @@ public class SecureNio2Channel extends N
                     //here we should trap BUFFER_OVERFLOW and call expand on 
the buffer
                     //for now, throw an exception, as we initialized the 
buffers
                     //in the constructor
-                    throw new ExecutionException(new IOException("Unable to 
unwrap data, invalid status: " + unwrap.getStatus()));
+                    throw new ExecutionException(new 
IOException(sm.getString("channel.nio.ssl.unwrapFail", unwrap.getStatus())));
                 }
             } while ((netInBuffer.position() != 0)); //continue to unwrapping 
as long as the input buffer has stuff
             return Integer.valueOf(read);
@@ -596,7 +613,7 @@ public class SecureNio2Channel extends N
         }
         //did we finish our handshake?
         if (!handshakeComplete)
-            throw new IllegalStateException("Handshake incomplete, you must 
complete handshake before reading data.");
+            throw new 
IllegalStateException(sm.getString("channel.nio.ssl.incompleteHandshake"));
         if (netInBuffer.position() > 0) {
             return new FutureRead(dst);
         } else {
@@ -612,7 +629,7 @@ public class SecureNio2Channel extends N
         protected FutureWrite(ByteBuffer src) {
             //are we closing or closed?
             if (closing || closed) {
-                t = new IOException("Channel is in closing state.");
+                t = new IOException(sm.getString("channel.nio.ssl.closing"));
                 return;
             }
             this.src = src;
@@ -673,7 +690,7 @@ public class SecureNio2Channel extends N
                     if (result.getHandshakeStatus() == 
HandshakeStatus.NEED_TASK)
                         tasks();
                 } else {
-                    t = new IOException("Unable to wrap data, invalid engine 
state: " +result.getStatus());
+                    t = new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus()));
                 }
                 integer = sc.write(netOutBuffer);
             } catch (SSLException e) {
@@ -742,7 +759,7 @@ public class SecureNio2Channel extends N
                         //here we should trap BUFFER_OVERFLOW and call expand 
on the buffer
                         //for now, throw an exception, as we initialized the 
buffers
                         //in the constructor
-                        throw new IOException("Unable to unwrap data, invalid 
status: " + unwrap.getStatus());
+                        throw new 
IOException(sm.getString("channel.nio.ssl.unwrapFail", unwrap.getStatus()));
                     }
                 } while ((netInBuffer.position() != 0)); //continue to 
unwrapping as long as the input buffer has stuff
                 // If everything is OK, so complete
@@ -777,7 +794,7 @@ public class SecureNio2Channel extends N
         }
         //did we finish our handshake?
         if (!handshakeComplete)
-            throw new IllegalStateException("Handshake incomplete, you must 
complete handshake before reading data.");
+            throw new 
IllegalStateException(sm.getString("channel.nio.ssl.incompleteHandshake"));
         ReadCompletionHandler<A> readCompletionHandler = new 
ReadCompletionHandler<>(dst, handler);
         if (netInBuffer.position() > 0 ) {
             
readCompletionHandler.completed(Integer.valueOf(netInBuffer.position()), 
attachment);
@@ -791,7 +808,7 @@ public class SecureNio2Channel extends N
             final A attachment, final CompletionHandler<Integer, ? super A> 
handler) {
         //are we closing or closed?
         if (closing || closed) {
-            handler.failed(new IOException("Channel is in closing state."), 
attachment);
+            handler.failed(new 
IOException(sm.getString("channel.nio.ssl.closing")), attachment);
             return;
         }
         if (writePending) {
@@ -812,7 +829,7 @@ public class SecureNio2Channel extends N
                     tasks();
             } else {
                 writePending = false;
-                handler.failed(new IOException("Unable to wrap data, invalid 
engine state: " +result.getStatus()), attachment);
+                handler.failed(new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus())), 
attachment);
                 return;
             }
             // Write data to the channel
@@ -896,7 +913,7 @@ public class SecureNio2Channel extends N
                         if (result.getHandshakeStatus() == 
HandshakeStatus.NEED_TASK)
                             tasks();
                     } else {
-                        failed(new IOException("Unable to wrap data, invalid 
engine state: " +result.getStatus()), attachment);
+                        failed(new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus())), 
attachment);
                         return;
                     }
                     if (written > 0) {
@@ -925,7 +942,7 @@ public class SecureNio2Channel extends N
         }
         //are we closing or closed?
         if (closing || closed) {
-            handler.failed(new IOException("Channel is in closing state."), 
attachment);
+            handler.failed(new 
IOException(sm.getString("channel.nio.ssl.closing")), attachment);
             return;
         }
         if (writePending) {
@@ -947,7 +964,7 @@ public class SecureNio2Channel extends N
                     tasks();
             } else {
                 writePending = false;
-                handler.failed(new IOException("Unable to wrap data, invalid 
engine state: " +result.getStatus()), attachment);
+                handler.failed(new 
IOException(sm.getString("channel.nio.ssl.wrapFail", result.getStatus())), 
attachment);
                 return;
             }
             // Write data to the channel

Modified: 
tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 
Fri Apr  4 10:10:28 2014
@@ -46,6 +46,7 @@ endpoint.poll.initfail=Poller creation f
 endpoint.poll.fail=Critical poller failure (restarting poller): [{0}] {1}
 endpoint.poll.error=Unexpected poller error
 endpoint.process.fail=Error allocating socket processor
+endpoint.processing.fail=Error running socket processor
 endpoint.sendfile.error=Unexpected sendfile error
 endpoint.sendfile.addfail=Sendfile failure: [{0}] {1}
 endpoint.setAttribute=Set [{0}] to [{1}]
@@ -59,4 +60,22 @@ endpoint.apr.pollError=Poller failed wit
 endpoint.apr.pollUnknownEvent=A socket was returned from the poller with an 
unrecognized event [{0}]
 endpoint.apr.remoteport=APR socket [{0}] opened with remote port [{1}]
 endpoint.nio.selectorCloseFail=Failed to close selector when closing the poller
-endpoint.nio2.exclusiveExecutor=The NIO2 connector requires an exclusive 
executor to operate properly
+endpoint.nio2.exclusiveExecutor=The NIO2 connector requires an exclusive 
executor to operate properly on shutdown
+
+channel.nio.ssl.notHandshaking=NOT_HANDSHAKING during handshake
+channel.nio.ssl.handhakeError=Handshake error
+channel.nio.ssl.unexpectedStatusDuringWrap=Unexpected status [{0}] during 
handshake WRAP.
+channel.nio.ssl.unexpectedStatusDuringUnwrap=Unexpected status [{0}] during 
handshake UNWRAP.
+channel.nio.ssl.invalidStatus=Unexpected status [{0}].
+channel.nio.ssl.netInputNotEmpty=Network input buffer still contains data. 
Handshake will fail.
+channel.nio.ssl.netOutputNotEmpty=Network output buffer still contains data. 
Handshake will fail.
+channel.nio.ssl.appInputNotEmpty=Application input buffer still contains data. 
Data would have been lost.
+channel.nio.ssl.appOutputNotEmpty=Application output buffer still contains 
data. Data would have been lost.
+channel.nio.ssl.eofDuringHandshake=EOF during handshake.
+channel.nio.ssl.remainingDataDuringClose=Remaining data in the network buffer, 
can't send SSL close message, force a close with close(true) instead
+channel.nio.ssl.pendingWriteDuringClose=Pending write, so remaining data in 
the network buffer, can't send SSL close message, force a close with 
close(true) instead
+channel.nio.ssl.invalidCloseState=Invalid close state, will not send network 
data.
+channel.nio.ssl.unwrapFail=Unable to unwrap data, invalid status [{0}]
+channel.nio.ssl.wrapFail=Unable to wrap data, invalid status [{0}]
+channel.nio.ssl.incompleteHandshake=Handshake incomplete, you must complete 
handshake before reading data.
+channel.nio.ssl.closing=Channel is in closing state.

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1584593&r1=1584592&r2=1584593&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Apr  4 10:10:28 2014
@@ -83,6 +83,9 @@
       <fix>
         Handle incomplete writes in NIO2, just in case. (remm)
       </fix>
+      <fix>
+        Code cleanups and i18n in NIO2. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">



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

Reply via email to