Repository: mina
Updated Branches:
  refs/heads/2.0 ca76211d0 -> 79c4f4173


Fix for DIRMINA-934/DIRMINA-1013


Project: http://git-wip-us.apache.org/repos/asf/mina/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/849e22af
Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/849e22af
Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/849e22af

Branch: refs/heads/2.0
Commit: 849e22afc822a5742756f5f729627cd4806ee717
Parents: bcf26ea
Author: Emmanuel Lécharny <elecha...@symas.com>
Authored: Wed Oct 7 18:30:25 2015 +0200
Committer: Emmanuel Lécharny <elecha...@symas.com>
Committed: Wed Oct 7 18:30:25 2015 +0200

----------------------------------------------------------------------
 .../apache/mina/filter/codec/ProtocolCodecFilter.java   | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina/blob/849e22af/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
----------------------------------------------------------------------
diff --git 
a/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java 
b/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
index c490226..30a1bcf 100644
--- 
a/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
+++ 
b/mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
@@ -21,7 +21,6 @@ package org.apache.mina.filter.codec;
 
 import java.net.SocketAddress;
 import java.util.Queue;
-import java.util.concurrent.Semaphore;
 
 import org.apache.mina.core.buffer.IoBuffer;
 import org.apache.mina.core.file.FileRegion;
@@ -66,8 +65,6 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
     /** The factory responsible for creating the encoder and decoder */
     private final ProtocolCodecFactory factory;
 
-    private final Semaphore lock = new Semaphore(1, true);
-
     /**
      * Creates a new instance of ProtocolCodecFilter, associating a factory
      * for the creation of the encoder and decoder.
@@ -228,9 +225,10 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
         while (in.hasRemaining()) {
             int oldPos = in.position();
             try {
-                lock.acquire();
-                // Call the decoder with the read bytes
-                decoder.decode(session, in, decoderOut);
+                synchronized (session) {
+                    // Call the decoder with the read bytes
+                    decoder.decode(session, in, decoderOut);
+                }
                 // Finish decoding if no exception was thrown.
                 decoderOut.flush(nextFilter, session);
             } catch (Exception e) {
@@ -257,8 +255,6 @@ public class ProtocolCodecFilter extends IoFilterAdapter {
                 if (!(e instanceof RecoverableProtocolDecoderException) || 
(in.position() == oldPos)) {
                     break;
                 }
-            } finally {
-                lock.release();
             }
         }
     }

Reply via email to