You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/06/25 00:46:38 UTC

svn commit: r1496247 - in /tomcat/trunk/java/org/apache/tomcat/websocket: AsyncChannelWrapperSecure.java LocalStrings.properties

Author: markt
Date: Mon Jun 24 22:46:38 2013
New Revision: 1496247

URL: http://svn.apache.org/r1496247
Log:
Remaining i18n TODOs in WebSocket impl

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java
    tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java?rev=1496247&r1=1496246&r2=1496247&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/AsyncChannelWrapperSecure.java Mon Jun 24 22:46:38 2013
@@ -36,12 +36,21 @@ import javax.net.ssl.SSLEngineResult.Han
 import javax.net.ssl.SSLEngineResult.Status;
 import javax.net.ssl.SSLException;
 
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * Wraps the {@link AsynchronousSocketChannel} with SSL/TLS. This needs a lot
  * more testing before it can be considered robust.
  */
 public class AsyncChannelWrapperSecure implements AsyncChannelWrapper {
 
+    private static final Log log =
+            LogFactory.getLog(AsyncChannelWrapperSecure.class);
+    private static final StringManager sm =
+            StringManager.getManager(Constants.PACKAGE_NAME);
+
     private static final ByteBuffer DUMMY = ByteBuffer.allocate(8192);
     private final AsynchronousSocketChannel socketChannel;
     private final SSLEngine sslEngine;
@@ -67,8 +76,8 @@ public class AsyncChannelWrapperSecure i
         WrapperFuture<Integer,Void> future = new WrapperFuture<>();
 
         if (!reading.compareAndSet(false, true)) {
-            // TODO
-            throw new IllegalStateException();
+            throw new IllegalStateException(sm.getString(
+                    "asyncChannelWrapperSecure.concurrentRead"));
         }
 
         ReadTask readTask = new ReadTask(dst, future);
@@ -86,8 +95,8 @@ public class AsyncChannelWrapperSecure i
                 new WrapperFuture<>(handler, attachment);
 
         if (!reading.compareAndSet(false, true)) {
-            // TODO
-            throw new IllegalStateException();
+            throw new IllegalStateException(sm.getString(
+                    "asyncChannelWrapperSecure.concurrentRead"));
         }
 
         ReadTask readTask = new ReadTask(dst, future);
@@ -101,8 +110,8 @@ public class AsyncChannelWrapperSecure i
         WrapperFuture<Long,Void> inner = new WrapperFuture<>();
 
         if (!writing.compareAndSet(false, true)) {
-            // TODO
-            throw new IllegalStateException();
+            throw new IllegalStateException(sm.getString(
+                    "asyncChannelWrapperSecure.concurrentWrite"));
         }
 
         WriteTask writeTask =
@@ -123,8 +132,8 @@ public class AsyncChannelWrapperSecure i
                 new WrapperFuture<>(handler, attachment);
 
         if (!writing.compareAndSet(false, true)) {
-            // TODO
-            throw new IllegalStateException();
+            throw new IllegalStateException(sm.getString(
+                    "asyncChannelWrapperSecure.concurrentWrite"));
         }
 
         WriteTask writeTask = new WriteTask(srcs, offset, length, future);
@@ -137,7 +146,7 @@ public class AsyncChannelWrapperSecure i
         try {
             socketChannel.close();
         } catch (IOException e) {
-            // TODO
+            log.info(sm.getString("asyncChannelWrapperSecure.closeFail"));
         }
     }
 
@@ -189,8 +198,8 @@ public class AsyncChannelWrapperSecure i
                         } else {
                             // Status.BUFFER_UNDERFLOW - only happens on unwrap
                             // Status.CLOSED - unexpected
-                            // TODO
-                            throw new IllegalStateException();
+                            throw new IllegalStateException(sm.getString(
+                                    "asyncChannelWrapperSecure.statusWrap"));
                         }
 
                         // Check for tasks
@@ -208,7 +217,10 @@ public class AsyncChannelWrapperSecure i
                         Future<Integer> f = socketChannel.write(socketWriteBuffer);
                         Integer socketWrite = f.get();
                         if (socketWrite.intValue() != r.bytesProduced()) {
-                            throw new IOException();
+                            throw new IOException(sm.getString(
+                                    "asyncChannelWrapperSecure.writeFail",
+                                    Integer.valueOf(socketWrite.intValue()),
+                                    Integer.valueOf(r.bytesProduced())));
                         }
                     }
                 }
@@ -217,8 +229,8 @@ public class AsyncChannelWrapperSecure i
                 if (writing.compareAndSet(true, false)) {
                     future.complete(Long.valueOf(written));
                 } else {
-                    // TODO
-                    future.fail(new IllegalStateException());
+                    future.fail(new IllegalStateException(sm.getString(
+                            "asyncChannelWrapperSecure.wrongStateWrite")));
                 }
             } catch (Exception e) {
                 future.fail(e);
@@ -252,8 +264,8 @@ public class AsyncChannelWrapperSecure i
                                 socketChannel.read(socketReadBuffer);
                         Integer socketRead = f.get();
                         if (socketRead.intValue() == -1) {
-                            // TODO
-                            throw new EOFException();
+                            throw new EOFException(sm.getString(
+                                    "asyncChannelWrapperSecure.eof"));
                         }
                     }
 
@@ -282,8 +294,8 @@ public class AsyncChannelWrapperSecure i
                             // partial data on the next read
                         } else {
                             // Status.CLOSED - unexpected
-                            // TODO
-                            throw new IllegalStateException();
+                            throw new IllegalStateException(sm.getString(
+                                    "asyncChannelWrapperSecure.statusUnwrap"));
                         }
 
                         // Check for tasks
@@ -303,8 +315,8 @@ public class AsyncChannelWrapperSecure i
                 if (reading.compareAndSet(true, false)) {
                     future.complete(Integer.valueOf(read));
                 } else {
-                    // TODO
-                    future.fail(new IllegalStateException());
+                    future.fail(new IllegalStateException(sm.getString(
+                            "asyncChannelWrapperSecure.wrongStateRead")));
                 }
             } catch (Exception e) {
                 future.fail(e);
@@ -510,8 +522,8 @@ public class AsyncChannelWrapperSecure i
         public Integer get() throws InterruptedException, ExecutionException {
             Long result = wrapped.get();
             if (result.longValue() > Integer.MAX_VALUE) {
-                // TODO
-                throw new ExecutionException("Result too big", null);
+                throw new ExecutionException(sm.getString(
+                        "asyncChannelWrapperSecure.tooBig", result), null);
             }
             return new Integer(result.intValue());
         }
@@ -522,8 +534,8 @@ public class AsyncChannelWrapperSecure i
                 TimeoutException {
             Long result = wrapped.get(timeout, unit);
             if (result.longValue() > Integer.MAX_VALUE) {
-                // TODO
-                throw new ExecutionException("Result too big", null);
+                throw new ExecutionException(sm.getString(
+                        "asyncChannelWrapperSecure.tooBig", result), null);
             }
             return new Integer(result.intValue());
         }

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties?rev=1496247&r1=1496246&r2=1496247&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/LocalStrings.properties Mon Jun 24 22:46:38 2013
@@ -13,6 +13,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+asyncChannelWrapperSecure.closeFail=Failed to close channel cleanly
+asyncChannelWrapperSecure.concurrentRead=Concurrent read operations are not permitted
+asyncChannelWrapperSecure.concurrentWrite=Concurrent write operations are not permitted
+asyncChannelWrapperSecure.eof=Unexpected end of stream
+asyncChannelWrapperSecure.statusUnwrap=Unexpected Status of SSLEngineResult after an unwrap() operation
+asyncChannelWrapperSecure.statusWrap=Unexpected Status of SSLEngineResult after a wrap() operation
+asyncChannelWrapperSecure.tooBig=The result [{0}] is too big to be expressed as an Integer
+asyncChannelWrapperSecure.wrongStateRead=Flag that indicates a read is in progress was found to be false (it should have been true) when trying to complete a read operation
+asyncChannelWrapperSecure.wrongStateWrite=Flag that indicates a write is in progress was found to be false (it should have been true) when trying to complete a write operation
+asyncChannelWrapperSecure.writeFail=Only wrote [{0}] of [{1}] bytes
+
 backgroundProcessManager.processFailed=A background process failed
 
 util.invalidType=Unable to coerce value [{0}] to type [{1}]. That type is not supported.



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