Ryuken SEKI created AMQ-4826:
--------------------------------
Summary: Avoid unnecessary remainder operator for floating-point
Key: AMQ-4826
URL: https://issues.apache.org/jira/browse/AMQ-4826
Project: ActiveMQ
Issue Type: Improvement
Components: activemq-camel
Affects Versions: 5.9.0
Environment: OS: OpenSUSE 12.2
JDK: Linux ARM Softfloat(jdk-7u45-linux-arm-vfp-sflt.tar.gz)
Hardware: pandaboard
Reporter: Ryuken SEKI
Priority: Minor
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.
--
This message was sent by Atlassian JIRA
(v6.1#6144)