directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r325858 - in /directory/network: branches/0.7/src/java/org/apache/mina/protocol/ branches/0.7/src/java/org/apache/mina/protocol/io/ trunk/src/java/org/apache/mina/filter/codec/
Date Mon, 17 Oct 2005 08:26:37 GMT
Author: trustin
Date: Mon Oct 17 01:26:18 2005
New Revision: 325858

URL: http://svn.apache.org/viewcvs?rev=325858&view=rev
Log:
Resolved: DIRMINA-94 Get rid of ProtocolViolationException.getBuffer()
* Replaced get/setBuffer with get/setHexdump()
* All buffers are now released properly even in case of ProtocolViolationException.



Modified:
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolViolationException.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolViolationException.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolViolationException.java?rev=325858&r1=325857&r2=325858&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolViolationException.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolViolationException.java
Mon Oct 17 01:26:18 2005
@@ -33,7 +33,7 @@
 {
     private static final long serialVersionUID = 3545799879533408565L;
 
-	private ByteBuffer buffer;
+	private String hexdump;
 
     /**
      * Constructs a new instance.
@@ -79,10 +79,10 @@
             message = "";
         }
 
-        if( buffer != null )
+        if( hexdump != null )
         {
             return message + ( ( message.length() > 0 ) ? " " : "" )
-                   + "(Hexdump: " + buffer.getHexDump() + ')';
+                   + "(Hexdump: " + hexdump + ')';
         }
         else
         {
@@ -91,18 +91,22 @@
     }
 
     /**
-     * Returns unknown message part.
+     * Returns the hexdump of the unknown message part.
      */
-    public ByteBuffer getBuffer()
+    public String getHexdump()
     {
-        return buffer;
+        return hexdump;
     }
 
     /**
-     * Sets unknown message part.
+     * Sets the hexdump of the unknown message part.
      */
-    public void setBuffer( ByteBuffer buffer )
+    public void setHexdump( String hexdump )
     {
-        this.buffer = buffer;
+        if( this.hexdump != null )
+        {
+            throw new IllegalStateException( "Hexdump cannot be set more than once." );
+        }
+        this.hexdump = hexdump;
     }
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java?rev=325858&r1=325857&r2=325858&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoAdapter.java Mon
Oct 17 01:26:18 2005
@@ -151,8 +151,7 @@
             }
             catch( ProtocolViolationException pve )
             {
-                in.acquire();  // Prevent the buffer from being released.
-                pve.setBuffer( in );
+                pve.setHexdump( in.getHexDump() );
                 managerFilterChain.exceptionCaught( psession, pve );
             }
             catch( Throwable t )

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=325858&r1=325857&r2=325858&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Mon Oct 17 01:26:18 2005
@@ -37,16 +37,17 @@
             {
                 decoder.decode( session, in, decoderOut );
             }
-            
-            in.release();
         }
         catch( ProtocolViolationException pve )
         {
-            pve.setBuffer( in );
+            pve.setHexdump( in.getHexDump() );
             throw pve;
         }
         finally
         {
+            // Release the read buffer.
+            in.release();
+            
             Queue queue = decoderOut.getMessageQueue();
             synchronized( queue )
             {

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java?rev=325858&r1=325857&r2=325858&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
Mon Oct 17 01:26:18 2005
@@ -33,7 +33,7 @@
 {
     private static final long serialVersionUID = 3545799879533408565L;
 
-	private ByteBuffer buffer;
+	private String hexdump;
 
     /**
      * Constructs a new instance.
@@ -79,10 +79,10 @@
             message = "";
         }
 
-        if( buffer != null )
+        if( hexdump != null )
         {
             return message + ( ( message.length() > 0 ) ? " " : "" )
-                   + "(Hexdump: " + buffer.getHexDump() + ')';
+                   + "(Hexdump: " + hexdump + ')';
         }
         else
         {
@@ -91,18 +91,22 @@
     }
 
     /**
-     * Returns unknown message part.
+     * Returns the hexdump of the unknown message part.
      */
-    public ByteBuffer getBuffer()
+    public String getHexdump()
     {
-        return buffer;
+        return hexdump;
     }
 
     /**
-     * Sets unknown message part.
+     * Sets the hexdump of the unknown message part.
      */
-    public void setBuffer( ByteBuffer buffer )
+    public void setHexdump( String hexdump )
     {
-        this.buffer = buffer;
+        if( this.hexdump != null )
+        {
+            throw new IllegalStateException( "Hexdump cannot be set more than once." );
+        }
+        this.hexdump = hexdump;
     }
 }



Mime
View raw message