Hello all,

I am using mina 2.0.8 since I needed a patch included in this release.

I face the following problem:

The concept of the application is to "multiplex" inbound to outbound
connections in MINA. This means that there might be 2 incoming connections
that are multiplexed in one outbound connection. During my tests i randomly
see this exception:

java.nio.InvalidMarkException
        at java.nio.Buffer.reset(Buffer.java:298) ~[?:1.7.0_40]
        at
org.apache.mina.core.buffer.AbstractIoBuffer.reset(AbstractIoBuffer.java:414)
~[mina-core-2.0.8-PATCHED.jar:?]
        at
org.apache.mina.core.polling.AbstractPollingIoProcessor.writeBuffer(AbstractPollingIoProcessor.java:926)
~[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flushNow(AbstractPollingIoProcessor.java:844)
[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
org.apache.mina.core.polling.AbstractPollingIoProcessor.flush(AbstractPollingIoProcessor.java:772)
[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$700(AbstractPollingIoProcessor.java:67)
[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1112)
[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
[mina-core-2.0.8-SNAPSHOT.jar:?]
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[?:1.7.0_40]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[?:1.7.0_40]
        at java.lang.Thread.run(Thread.java:724) [?:1.7.0_40]

After some investigation i noticed that this happened when 2 threads
decided to write to the same IoSession a message the same time. My
assumption is that the #IoSession.write method is not thread safe, thus i
synchronized the session instance before executing the write method in my
handlers and up until now i haven't faced the same issue. Is my assumption
valid?

Thank you in advance,
Alex

Reply via email to