IllegalArgumentException thrown from ErrorGeneratingFilter
----------------------------------------------------------

                 Key: DIRMINA-739
                 URL: https://issues.apache.org/jira/browse/DIRMINA-739
             Project: MINA
          Issue Type: Bug
          Components: Filter
    Affects Versions: 2.0.0-M6
            Reporter: Stephen Crane


I've configured an ErrorGeneratingFilter in my tests and am now occasionally 
seeing the following exception:

{code}
Caused by: java.lang.IllegalArgumentException: n must be positive
        at java.util.Random.nextInt(Random.java:250)
        at 
org.apache.mina.filter.errorgenerating.ErrorGeneratingFilter.manipulateIoBuffer(ErrorGeneratingFilter.java:187)
        at 
org.apache.mina.filter.errorgenerating.ErrorGeneratingFilter.messageReceived(ErrorGeneratingFilter.java:118)
        at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:433)
{code}

Obviously buffer.remaining() is returning 0 here.

How about the following fix?

{code}
if (buffer.remaining() > 0 && changeByteProbability > rng.nextInt(1000)) {
        // as before
}
{code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to