This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 8ad606b  Issue 1510: java.lang.IllegalArgumentException on refreshing 
stats (#1524)
8ad606b is described below

commit 8ad606b0c7173a991df540855c588072f5ab5c34
Author: Sijie Guo <guosi...@gmail.com>
AuthorDate: Sun Apr 8 09:12:39 2018 -0700

    Issue 1510: java.lang.IllegalArgumentException on refreshing stats (#1524)
---
 .../bookkeeper/mledger/impl/ManagedLedgerFactoryMBeanImpl.java       | 5 +++++
 .../src/main/java/org/apache/bookkeeper/mledger/util/Rate.java       | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryMBeanImpl.java
 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryMBeanImpl.java
index b97fda6..8d25b88 100644
--- 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryMBeanImpl.java
+++ 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryMBeanImpl.java
@@ -38,6 +38,11 @@ public class ManagedLedgerFactoryMBeanImpl implements 
ManagedLedgerFactoryMXBean
     public void refreshStats(long period, TimeUnit unit) {
         double seconds = unit.toMillis(period) / 1000.0;
 
+        if (seconds <= 0.0) {
+            // skip refreshing stats
+            return;
+        }
+
         cacheHits.calculateRate(seconds);
         cacheMisses.calculateRate(seconds);
         cacheEvictions.calculateRate(seconds);
diff --git 
a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/Rate.java 
b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/Rate.java
index 2b8e018..504d5d9 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/Rate.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/util/Rate.java
@@ -57,7 +57,7 @@ public class Rate {
     }
 
     public void calculateRate(double period) {
-        checkArgument(period != 0);
+        checkArgument(period > 0, "Invalid period %s to calculate rate", 
period);
 
         count = countAdder.sumThenReset();
         long sum = valueAdder.sumThenReset();

-- 
To stop receiving notification emails like this one, please contact
mme...@apache.org.

Reply via email to