directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r419506 - in /directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec: ProtocolCodecFilter.java support/SimpleProtocolDecoderOutput.java support/SimpleProtocolEncoderOutput.java
Date Thu, 06 Jul 2006 10:08:09 GMT
Author: trustin
Date: Thu Jul  6 03:08:08 2006
New Revision: 419506

URL: http://svn.apache.org/viewvc?rev=419506&view=rev
Log:
Fixed issue: DIRMINA-225 (Possible parameter corruption for messageSent event.)
* Change ProtocolCodecFilter to create ProtocolEncoderOutput everytime 

Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=419506&r1=419505&r2=419506&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Thu Jul  6 03:08:08 2006
@@ -42,7 +42,6 @@
 {
     public static final String ENCODER = ProtocolCodecFilter.class.getName() + ".encoder";
     public static final String DECODER = ProtocolCodecFilter.class.getName() + ".decoder";
-    public static final String ENCODER_OUT = ProtocolCodecFilter.class.getName() + ".encoderOutput";
     
     private static final Class[] EMPTY_PARAMS = new Class[0];
 
@@ -149,7 +148,7 @@
 
         ByteBuffer in = ( ByteBuffer ) message;
         ProtocolDecoder decoder = getDecoder( session );
-        ProtocolDecoderOutput decoderOut = createDecoderOut( nextFilter, session );
+        ProtocolDecoderOutput decoderOut = getDecoderOut( session, nextFilter );
         
         try
         {
@@ -213,12 +212,10 @@
         }
 
         ProtocolEncoder encoder = getEncoder( session );
-        ProtocolEncoderOutputImpl encoderOut = getEncoderOut( session );
-        encoderOut.nextFilter = nextFilter;
+        ProtocolEncoderOutputImpl encoderOut = getEncoderOut( session, nextFilter, writeRequest
);
         
         try
         {
-            encoderOut.writeRequest = writeRequest;
             encoder.encode( session, message, encoderOut );
         }
         catch( Throwable t )
@@ -237,7 +234,6 @@
         finally
         {
             encoderOut.flush();
-            encoderOut.writeRequest = null;
 
             // Dispose the encoder if this session is connectionless.
             if( session.getTransportType().isConnectionless() )
@@ -265,15 +261,9 @@
         return encoder;
     }
     
-    private ProtocolEncoderOutputImpl getEncoderOut( IoSession session )
+    private ProtocolEncoderOutputImpl getEncoderOut( IoSession session, NextFilter nextFilter,
WriteRequest writeRequest )
     {
-        ProtocolEncoderOutputImpl out = ( ProtocolEncoderOutputImpl ) session.getAttribute(
ENCODER_OUT );
-        if( out == null )
-        {
-            out = new ProtocolEncoderOutputImpl( session );
-            session.setAttribute( ENCODER_OUT, out );
-        }
-        return out;
+        return new ProtocolEncoderOutputImpl( session, nextFilter, writeRequest );
     }
     
     private ProtocolDecoder getDecoder( IoSession session ) throws Exception
@@ -287,14 +277,13 @@
         return decoder;
     }
     
-    protected ProtocolDecoderOutput createDecoderOut( NextFilter nextFilter, IoSession session
)
+    private ProtocolDecoderOutput getDecoderOut( IoSession session, NextFilter nextFilter
)
     {
-        return new SimpleProtocolDecoderOutput( nextFilter, session );
+        return new SimpleProtocolDecoderOutput( session, nextFilter );
     }
     
     private void disposeEncoder( IoSession session )
     {
-        session.removeAttribute( ENCODER_OUT );
         ProtocolEncoder encoder = ( ProtocolEncoder ) session.removeAttribute( ENCODER );
         if( encoder == null )
         {
@@ -349,12 +338,14 @@
     private static class ProtocolEncoderOutputImpl extends SimpleProtocolEncoderOutput
     {
         private final IoSession session;
-        private NextFilter nextFilter;
-        private WriteRequest writeRequest;
+        private final NextFilter nextFilter;
+        private final WriteRequest writeRequest;
         
-        public ProtocolEncoderOutputImpl( IoSession session )
+        public ProtocolEncoderOutputImpl( IoSession session, NextFilter nextFilter, WriteRequest
writeRequest )
         {
             this.session = session;
+            this.nextFilter = nextFilter;
+            this.writeRequest = writeRequest;
         }
 
         protected WriteFuture doFlush( ByteBuffer buf )

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java?rev=419506&r1=419505&r2=419506&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
Thu Jul  6 03:08:08 2006
@@ -21,7 +21,7 @@
     private final IoSession session;
     private final Queue messageQueue = new Queue();
     
-    public SimpleProtocolDecoderOutput( NextFilter nextFilter, IoSession session )
+    public SimpleProtocolDecoderOutput( IoSession session, NextFilter nextFilter )
     {
         this.nextFilter = nextFilter;
         this.session = session;

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java?rev=419506&r1=419505&r2=419506&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java
Thu Jul  6 03:08:08 2006
@@ -27,12 +27,12 @@
         return bufferQueue;
     }
     
-    public synchronized void write( ByteBuffer buf )
+    public void write( ByteBuffer buf )
     {
         bufferQueue.push( buf );
     }
     
-    public synchronized void mergeAll()
+    public void mergeAll()
     {
         int sum = 0;
         final int size = bufferQueue.size();
@@ -70,7 +70,7 @@
         bufferQueue.push(newBuf);
     }
     
-    public synchronized WriteFuture flush()
+    public WriteFuture flush()
     {
         Queue bufferQueue = this.bufferQueue;
         WriteFuture future = null;



Mime
View raw message