diff --git a/README.markdown b/README.markdown index 109120fd..ae6add4a 100644 --- a/README.markdown +++ b/README.markdown @@ -37,7 +37,7 @@ At the moment following grids are supported: ### Get Bucket4j library #### By direct link -[Download compiled jar, sources, javadocs](https://github.com/vladimir-bukhtoyarov/bucket4j/releases/tag/bucket4j-1.0.0) +[Download compiled jar, sources, javadocs](https://github.com/vladimir-bukhtoyarov/bucket4j/releases/tag/bucket4j-1.0.1) #### You can build Bucket4j from sources @@ -66,7 +66,7 @@ Then include Bucket4j as dependency to your `pom.xml` com.github bucket4j - 1.0.0 + 1.0.1 ``` diff --git a/pom.xml b/pom.xml index 5d14d75d..2d322346 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ com.github bucket4j - 1.0.0 + 1.0.1 jar bucket4j @@ -44,8 +44,8 @@ http://github.com/vladimir-bukhtoyarov/bucket4j scm:git:git@github.com:vladimir-bukhtoyarov/bucket4j scm:git:git@github.com:vladimir-bukhtoyarov/bucket4j.git - bucket4j-1.0.0 - + bucket4j-1.0.1 + diff --git a/src/main/java/com/github/bucket4j/local/LockFreeBucket.java b/src/main/java/com/github/bucket4j/local/LockFreeBucket.java index 8bac15cd..132c595c 100644 --- a/src/main/java/com/github/bucket4j/local/LockFreeBucket.java +++ b/src/main/java/com/github/bucket4j/local/LockFreeBucket.java @@ -87,7 +87,7 @@ protected boolean consumeOrAwaitImpl(long tokensToConsume, long waitIfBusyTimeLi Bandwidth[] bandwidths = configuration.getBandwidths(); boolean isWaitingLimited = waitIfBusyTimeLimit > 0; - final long methodStartTime = isWaitingLimited? configuration.getTimeMeter().currentTime(): 0; + final long methodStartTime = configuration.getTimeMeter().currentTime(); long currentTime = methodStartTime; long methodDuration = 0; boolean isFirstCycle = true; diff --git a/src/test/java/regression/LocalBucketTest.java b/src/test/java/regression/LocalBucketTest.java new file mode 100644 index 00000000..fed6e984 --- /dev/null +++ b/src/test/java/regression/LocalBucketTest.java @@ -0,0 +1,24 @@ +package regression; + +import com.github.bucket4j.Bucket; +import com.github.bucket4j.Buckets; +import org.junit.Test; + +import java.util.concurrent.TimeUnit; + +public class LocalBucketTest { + + /** + * Found in the version 1.0.0 + * + * Test that local bucket does not hang + * + * @throws InterruptedException + */ + @Test(timeout = 3000) + public void testConsumeOrAwait() throws InterruptedException { + Bucket bucket = Buckets.withNanoTimePrecision().withLimitedBandwidth(100, TimeUnit.MILLISECONDS, 1, 0).build(); + bucket.consumeSingleToken(); + } + +}