You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by tr...@apache.org on 2007/11/19 00:45:32 UTC

svn commit: r596161 - /mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java

Author: trustin
Date: Sun Nov 18 15:45:27 2007
New Revision: 596161

URL: http://svn.apache.org/viewvc?rev=596161&view=rev
Log:
Fixed a bug in DefaultReadFuture that Exception as a message is not allowed.

Modified:
    mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java

Modified: mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java
URL: http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java?rev=596161&r1=596160&r2=596161&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java (original)
+++ mina/trunk/core/src/main/java/org/apache/mina/common/DefaultReadFuture.java Sun Nov 18 15:45:27 2007
@@ -46,7 +46,8 @@
                 return null;
             }
             
-            if (v instanceof Throwable) {
+            if (v instanceof ExceptionHolder) {
+                v = ((ExceptionHolder) v).exception;
                 if (v instanceof RuntimeException) {
                     throw (RuntimeException) v;
                 }
@@ -73,7 +74,7 @@
     public boolean isRead() {
         if (isReady()) {
             Object v = getValue();
-            return (v != CLOSED && !(v instanceof Throwable));
+            return (v != CLOSED && !(v instanceof ExceptionHolder));
         }
         return false;
     }
@@ -88,8 +89,8 @@
     public Throwable getException() {
         if (isReady()) {
             Object v = getValue();
-            if (v instanceof Throwable) {
-                return (Throwable) v;
+            if (v instanceof ExceptionHolder) {
+                return ((ExceptionHolder) v).exception;
             }
         }
         return null;
@@ -104,7 +105,7 @@
     }
 
     public void setException(Throwable cause) {
-        setValue(cause);
+        setValue(new ExceptionHolder(cause));
     }
 
     @Override
@@ -125,5 +126,13 @@
     @Override
     public ReadFuture removeListener(IoFutureListener<?> listener) {
         return (ReadFuture) super.removeListener(listener);
+    }
+    
+    private static class ExceptionHolder {
+        private final Throwable exception;
+        
+        private ExceptionHolder(Throwable exception) {
+            this.exception = exception;
+        }
     }
 }