[ https://issues.apache.org/jira/browse/DIRMINA-536?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Trustin Lee resolved DIRMINA-536. --------------------------------- Resolution: Fixed Fixed as you suggested. Please close this issue if it resolves your problem. > 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 > Assignee: Trustin Lee > Fix For: 1.0.10, 1.1.7, 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.