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)
This commit is contained in:
Christopher L. Shannon (cshannon) 2016-07-14 10:07:02 -04:00
parent c3d71ebe01
commit 78cacc5e17

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;
} }