You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Emmanuel Lecharny (JIRA)" <ji...@apache.org> on 2014/08/30 04:54:53 UTC
[jira] [Commented] (DIRMINA-982) ProtocolEncoderOutputImpl.flush()
throws an IllegalArgumentException if buffers queue is empty
[ https://issues.apache.org/jira/browse/DIRMINA-982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14116198#comment-14116198 ]
Emmanuel Lecharny commented on DIRMINA-982:
-------------------------------------------
I'm not sure what you are suggesting here...
Do you think that we should always send back a Future instead of null, even if the queue is empty ?
Now, regarding the Stack trace you get, you clearly have a race condition occuring. In the flush method, we do :
{code}
while (!bufferQueue.isEmpty()) {
Object encodedMessage = bufferQueue.poll();
if (encodedMessage == null) {
break;
}
nextFilter.filterWrite(session, new EncodedWriteRequest(encodedMessage, future, destination));
}
{code}
(I removed the irrelevant parts)
The new EncodedWriteRequest() part will call the super constructor, which does :
{code}
public DefaultWriteRequest(Object message, WriteFuture future, SocketAddress destination) {
if (message == null) {
throw new IllegalArgumentException("message");
}
{code}
At this point, the message should never be null. If it's null, that means the encodedMessage has been nullified between the if (encodedMessage == null ) test and the construction of the EncodedWriteRequest...
> ProtocolEncoderOutputImpl.flush() throws an IllegalArgumentException if buffers queue is empty
> ----------------------------------------------------------------------------------------------
>
> Key: DIRMINA-982
> URL: https://issues.apache.org/jira/browse/DIRMINA-982
> Project: MINA
> Issue Type: Bug
> Affects Versions: 2.0.7
> Reporter: Jenya Pisarenko
>
> https://git-wip-us.apache.org/repos/asf?p=mina.git;a=blob;f=mina-core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java;h=f413491e058ff1c5a24c3b2ccae6d736f481bbaf;hb=2.0#l428
> First, flush method initializes WriteFuture with a null reference.
> The object can be constructed later, if buffers queue isn't empty, but otherwise remains untouched.
> If it still holds a null reference, the DefaultWriteRequest constructor call always fails, as it doesn't accept null as a message param.
> Excerpt from the stack trace:
> {noformat}
> Caused by: java.lang.IllegalArgumentException: message
> at org.apache.mina.core.write.DefaultWriteRequest.<init>(DefaultWriteRequest.java:133)
> at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolEncoderOutputImpl.flush(ProtocolCodecFilter.java:448)
> at com.ugcs.messaging.mina.MinaEncoder.encode(MinaEncoder.java:27)
> at org.apache.mina.filter.codec.ProtocolCodecFilter.filterWrite(ProtocolCodecFilter.java:308)
> ... 33 more
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.2#6252)