You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Ryuken SEKI (JIRA)" <ji...@apache.org> on 2013/10/25 10:35:30 UTC
[jira] [Created] (AMQ-4826) Avoid unnecessary remainder operator
for floating-point
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)