[jboss-jira] [JBoss JIRA] (JBMESSAGING-1913) JBoss Messaging throws an java.lang.IllegalArgumentException exception

Tom Ross (JIRA) jira-events at lists.jboss.org
Fri Feb 17 10:27:36 EST 2012


Tom Ross created JBMESSAGING-1913:
-------------------------------------

             Summary: JBoss Messaging throws an java.lang.IllegalArgumentException exception 
                 Key: JBMESSAGING-1913
                 URL: https://issues.jboss.org/browse/JBMESSAGING-1913
             Project: JBoss Messaging
          Issue Type: Bug
          Components: JMS Client Manager
         Environment: JBoss EAP 5.1.2
            Reporter: Tom Ross
            Assignee: Yong Hao Gao
             Fix For: 1.4.8.SP5, 1.4.7.GA


The code for org.jboss.jms.client.plugin.RoundRobinLoadBalancingPolicy.getNext() method calls Random.nextInt(int n) with negative argument. This is wrong since the Java JDK 1.6 documentation states that the nextInt(int n) method must be called with a positive number. 


This is method implementation as per JDK 1.6 documentation.

public int nextInt(int n) {
   if (n <= 0)
     throw new IllegalArgumentException("n must be positive");

   if ((n & -n) == n)  // i.e., n is a power of 2
     return (int)((n * (long)next(31)) >> 31);

   int bits, val;
   do {
       bits = next(31);
       val = bits % n;
   } while (bits - val + (n-1) < 0);
   return val;
 }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list