Repository: activemq Updated Branches: refs/heads/activemq-5.13.x c3d71ebe0 -> 78cacc5e1
https://issues.apache.org/jira/browse/AMQ-6357 Preventing a divide by 0 error by taking a local reference to the prefetch size to guarantee that the value doesn't change after the > 0 check (cherry picked from commit 42dabb7a7a7f981eb57d46663456ac1d7c912acb) Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/78cacc5e Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/78cacc5e Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/78cacc5e Branch: refs/heads/activemq-5.13.x Commit: 78cacc5e17b6d5a93ff3b857043a3f5879e48edd Parents: c3d71eb Author: Christopher L. Shannon (cshannon) <[email protected]> Authored: Thu Jul 14 10:07:02 2016 -0400 Committer: Christopher L. Shannon (cshannon) <[email protected]> Committed: Thu Jul 14 10:17:25 2016 -0400 ---------------------------------------------------------------------- .../org/apache/activemq/broker/region/AbstractSubscription.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq/blob/78cacc5e/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java ---------------------------------------------------------------------- diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java index e03ca32..1d84269 100755 --- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java +++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/AbstractSubscription.java @@ -236,8 +236,9 @@ public abstract class AbstractSubscription implements Subscription { @Override public int getInFlightUsage() { - if (info.getPrefetchSize() > 0) { - return (getInFlightSize() * 100)/info.getPrefetchSize(); + int prefetchSize = info.getPrefetchSize(); + if (prefetchSize > 0) { + return (getInFlightSize() * 100) / prefetchSize; } return Integer.MAX_VALUE; }
