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
This commit is contained in:
Christopher L. Shannon (cshannon) 2016-07-14 10:07:02 -04:00
parent 4b2760e749
commit 42dabb7a7a
1 changed files with 3 additions and 2 deletions

View File

@ -236,8 +236,9 @@ public abstract class AbstractSubscription implements Subscription {
@Override @Override
public int getInFlightUsage() { public int getInFlightUsage() {
if (info.getPrefetchSize() > 0) { int prefetchSize = info.getPrefetchSize();
return (getInFlightSize() * 100)/info.getPrefetchSize(); if (prefetchSize > 0) {
return (getInFlightSize() * 100) / prefetchSize;
} }
return Integer.MAX_VALUE; return Integer.MAX_VALUE;
} }