Hello, First, I want to say that I’m not sure it’s a problem in Mina or the way we use it in our project.
Context and mina version: I’m currently trying to upgrade the mina version used in my project from mina 2.0.7 to 2.1.X (first trying to 2.1.7 then maybe to 2.1.10). The problem : The class AbstractIoSession has a member scheduledWriteMessages. It is increased when HeadFilter.filterWrite is called (file DefaultIoFilterChain.java) ; then it is decreased when the message is sent. In my problematic case, I use a ProtocolCodecFilter and for some message, when the filterWrite method is called, it goes into this while loop : // Code in ProtocolCodecFilter.java // Write all the encoded messages now while (!bufferQueue.isEmpty()) { Object encodedMessage = bufferQueue.poll(); if (encodedMessage == null) { break; } // Flush only when the buffer has remaining. if (!(encodedMessage instanceof IoBuffer) || ((IoBuffer) encodedMessage).hasRemaining()) { if (bufferQueue.isEmpty()) { writeRequest.setMessage(encodedMessage); nextFilter.filterWrite(session, writeRequest); } else { SocketAddress destination = writeRequest.getDestination(); WriteRequest encodedWriteRequest = new EncodedWriteRequest(encodedMessage, null, destination); nextFilter.filterWrite(session, encodedWriteRequest); } } } // Fin Code in ProtocolCodecFilter.java Here we see 2 calls of nextFilter.filterWrite. In my case, the loop is done 3 times so nextFilter.filterWrite is called 2 times with a new EncodedWriteRequest and once (the last) by passing the processed WriteRequest. Those 3 calls end up to HeadFilter.filterWrite and so scheduledWriteMessages is then equal to 3. When the message is sent, scheduledWriteMessages is decreased only once so now scheduledWriteMessages is 2. I’ve noticed the problem appeared in 2.1.1 with this commit : “2d08d53 - Pushed my current changes related to the filterWrite refactoring” diff --git a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java --- a/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java +++ b/mina-core/src/main/java/org/apache/mina/core/filterchain/DefaultIoFilterChain.java @@ -907,4 +906,2 @@ - if (!writeRequest.isEncoded()) { - s.increaseScheduledWriteMessages(); - } + s.increaseScheduledWriteMessages(); So before this commit, increaseScheduledWriteMessages was called only once as the 2 first time the writeRequest isEncoded. This scheduledWriteMessages is not used in mina (src or test), but in my project, we used it to check connection problems. As a temporary fix, I just removed the use of scheduledWriteMessages; and I thought a possible patch for mina would be to recheck the isEncoded like in 2.1.0. BUT ! Then I tried using mina 2.1.10 and a new problem arise with the same message. So, a bit more of context: * The client sends the problematic request message * The server receives the request (triggering the 3 scheduledWriteMessages increase) * The it sends the associated response. With mina 2.1.7, the client received one response and everything works after that, but not with mina 2.1.10 where for the next good request I receive a response for the previous problematic request and then the good response. For clarity let’s call the problematic request and response PRqst and PResp , and let’s call anther Good Request/Response GRqst/GResp. From my client I see that : * Send PRqst * Receive PResp * Wait some time // The problem appears wether I add this wait or not * Send GRqst * Receive PResp * Receive GResp So, because of this problem, I don’t know if it is a problem in Mina or how I use it. I searched the commits between 2.1.7 and 2.1.10 for clues, but could not find anything. If someone could give me some more info, that would be great 😊 Thanks, and have a nice day. RM