Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-4826

Avoid unnecessary remainder operator for floating-point

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 5.9.0
    • 5.9.1, 5.10.0
    • Transport
    • None
    • OS: OpenSUSE 12.2
      JDK: Linux ARM Softfloat(jdk-7u45-linux-arm-vfp-sflt.tar.gz)
      Hardware: pandaboard

    Description

      I installed jdk-7u45-linux-arm-vfp-sflt.tar.gz on my pandaboard, and found that this jdk has a problem of remainder operator for floating point. So, if you starts ActiveMQ in above environment, you might encounter IndexOutOfBoundsException at
      org.apache.activemq.transport.failover.FailoverTransport.getConnectList(FailoverTransport.java:779)

      This is because
      int p = (int) (Math.random() * 100 % l.size());
      above p gets larger number than "l.size" contrary to your expectation. This problem doesn't occur in case of x86 Architecture or ARM Hardfloat JDK.

      This is a problem of ARM Softfloat JDK, but I think it's better to avoid unnecessary remainder operator for floating-point for safety. So,
      int p = ((int) Math.random() * 100) % l.size();
      would be better than current one.

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            ryuken Ryuken SEKI
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: