Author: toad
Date: 2008-04-18 12:49:41 +0000 (Fri, 18 Apr 2008)
New Revision: 19388
Modified:
trunk/freenet/src/freenet/support/TokenBucket.java
Log:
Limit current to max in the constructor rather than later. Complain if it's too
high.
Modified: trunk/freenet/src/freenet/support/TokenBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/TokenBucket.java 2008-04-18 12:10:11 UTC
(rev 19387)
+++ trunk/freenet/src/freenet/support/TokenBucket.java 2008-04-18 12:49:41 UTC
(rev 19388)
@@ -21,6 +21,10 @@
public TokenBucket(long max, long nanosPerTick, long initialValue) {
this.max = max;
this.current = initialValue;
+ if(current > max) {
+ Logger.error(this, "current ("+current+") > max
("+max+") in "+this);
+ current = max;
+ }
this.nanosPerTick = nanosPerTick;
long now = System.currentTimeMillis();
this.timeLastTick = now * (1000 * 1000);