Repository: activemq Updated Branches: refs/heads/master 4b2760e74 -> 42dabb7a7
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 Project: http://git-wip-us.apache.org/repos/asf/activemq/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/42dabb7a Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/42dabb7a Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/42dabb7a Branch: refs/heads/master Commit: 42dabb7a7a7f981eb57d46663456ac1d7c912acb Parents: 4b2760e 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:07:02 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/42dabb7a/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; }
