[
https://issues.apache.org/jira/browse/DIRMINA-536?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12576484#action_12576484
]
Mark Webb commented on DIRMINA-536:
-----------------------------------
Where does the class TestDecoderOutput come from?
> TextLineDecoder throws an IndexOutOfBoundsException
> ---------------------------------------------------
>
> Key: DIRMINA-536
> URL: https://issues.apache.org/jira/browse/DIRMINA-536
> Project: MINA
> Issue Type: Bug
> Components: Filter
> Affects Versions: 1.0.9, 1.1.6, 2.0.0-M1
> Environment: All versions in any environnement
> Reporter: Edouard De Oliveira
> Fix For: 2.0.0-M2
>
> Original Estimate: 0.25h
> Remaining Estimate: 0.25h
>
> Adding the following test to the TextLineDecoderTest JUNIT test class will
> raise the bug.
> It's due to an incomplete match being incorrectly rewinded that causes the
> IndexOutOfBoundsException
>
> public void testSMTPDataBounds() throws Exception {
> TextLineDecoder decoder = new
> TextLineDecoder(Charset.forName("ISO-8859-1"),
> new LineDelimiter("\r\n.\r\n"));
> CharsetEncoder encoder = Charset.forName("ISO-8859-1").newEncoder();
> IoSession session = new DummySession();
> TestDecoderOutput out = new TestDecoderOutput();
> ByteBuffer in = ByteBuffer.allocate(16).setAutoExpand(true);
> in.putString("\r\n", encoder).flip().mark();
> decoder.decode(session, in.reset().mark(), out);
> Assert.assertEquals(0, out.getMessageQueue().size());
> in.putString("Body\r\n.\r\n", encoder).flip().mark();
> decoder.decode(session, in.reset().mark(), out);
> Assert.assertEquals(1, out.getMessageQueue().size());
> }
> ------
> To solve the issue, a simple patch is to replace the following line in
> org.apache.mina.filter.codec.textline.TextLineDecoder.java :
> in.position(in.position()-matchCount);
> by
> in.position(Math.max(0, in.position()-matchCount));
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.