You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Jörg Michelberger (JIRA)" <ji...@apache.org> on 2019/03/21 14:10:00 UTC

[jira] [Created] (DIRMINA-1101) InvalidMarkException on session.write when using CompressionFilter.

Jörg Michelberger created DIRMINA-1101:
------------------------------------------

             Summary: InvalidMarkException on session.write when using CompressionFilter.
                 Key: DIRMINA-1101
                 URL: https://issues.apache.org/jira/browse/DIRMINA-1101
             Project: MINA
          Issue Type: Bug
    Affects Versions: 2.0.20
            Reporter: Jörg Michelberger


I'm updated from a MINA 2.0.7 to the 2.0.20 and am a user of CompressionFilter. Writing of Messages fails with a InvalidMarkException.

Reproducible Test is:
 * Copy MINA Core Test org.apache.mina.core.service.AbstractIoServiceTest to MINA Compression Filter org.apache.mina.filter.compression Test Packages package.
 * Adapt package statement to org.apache.mina.filter.compression.
 * Add Compression to acceptor and connector
 *         acceptor.getFilterChain().addLast("compression", new CompressionFilter());
        acceptor.getFilterChain().addLast("logger", new LoggingFilter());
        acceptor.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(StandardCharsets.UTF_8)));
 *         connector.getFilterChain().addLast("compression", new CompressionFilter());
        connector.getFilterChain().addLast("logger", new LoggingFilter());
        connector.getFilterChain().addLast("codec",
                new ProtocolCodecFilter(new TextLineCodecFactory(StandardCharsets.UTF_8)));
 * Set a Breakpoint to java.nio.Buffer.reset() method, where the InvalidMarkException is thrown.
 * Run Debug Testfile on org.apache.mina.filter.compression.AbstractIoServiceTest 

After the Exception the session is immediatelly scheduled for disconnect.

It seems that there is a discrepancy between the mark() and reset() calls on the underlaying Buffer. In case of compression, a Buffer with the compressed content is created and is wrapped with the original Buffer in a FilteredWriteRequest, because CompressionFilter is a WriteRequestFilter. This is in WriteRequestFilter.filterWrite()

In DefaultIoFilterChain$HeadFilter.filterWrite() is then the mark() call, which is done on the compressed Buffer.

In AbstractPollingIoProcessor.writeBuffer() is the reset() call, which is in this case done on the original Buffer, leading to the Exception.

{{java.nio.InvalidMarkException}}
{{    at java.nio.Buffer.reset(Buffer.java:306)}}
{{    at org.apache.mina.core.buffer.AbstractIoBuffer.reset(AbstractIoBuffer.java:425)}}
{{    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.writeBuffer(AbstractPollingIoProcessor.java:1131)}}
{{    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.flushNow(AbstractPollingIoProcessor.java:994)}}
{{    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.flush(AbstractPollingIoProcessor.java:921)}}
{{    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:688)}}
{{    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)}}
{{    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)}}
{{    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)}}
{{    at java.lang.Thread.run(Thread.java:748)}}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)