From 111592751a4729e1886576b8f953b36ca35d2151 Mon Sep 17 00:00:00 2001 From: Fabio Lima Date: Mon, 24 Feb 2020 00:03:38 -0300 Subject: [PATCH] Remove method from GuidCreator The method withoutOverrunException() is not necessary anymore. --- README.md | 3 +-- .../com/github/f4b6a3/ulid/UlidCreator.java | 4 ++-- .../github/f4b6a3/ulid/guid/GuidCreator.java | 20 +------------------ 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 190165a..b44ec40 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Add these lines to your `pom.xml`. com.github.f4b6a3 ulid-creator - 1.0.0 + 1.0.1 ``` See more options in [maven.org](https://search.maven.org/artifact/com.github.f4b6a3/ulid-creator) and [mvnrepository.com](https://mvnrepository.com/artifact/com.github.f4b6a3/ulid-creator). @@ -160,4 +160,3 @@ String ulid = UlidCreator.getGuidCreator() .createUlid(); ``` -If you use the `GuidCreator` directly, you need do handle the `UlidCreatorException`, in the case that too many ULIDs are requested within the same millisecond. diff --git a/src/main/java/com/github/f4b6a3/ulid/UlidCreator.java b/src/main/java/com/github/f4b6a3/ulid/UlidCreator.java index 5ee9b2e..ef51584 100644 --- a/src/main/java/com/github/f4b6a3/ulid/UlidCreator.java +++ b/src/main/java/com/github/f4b6a3/ulid/UlidCreator.java @@ -108,10 +108,10 @@ public class UlidCreator { } private static class GuidCreatorLazyHolder { - static final GuidCreator INSTANCE = getGuidCreator().withoutOverrunException(); + static final GuidCreator INSTANCE = getGuidCreator(); } private static class FastGuidCreatorLazyHolder { - static final GuidCreator INSTANCE = getGuidCreator().withFastRandomGenerator().withoutOverrunException(); + static final GuidCreator INSTANCE = getGuidCreator().withFastRandomGenerator(); } } diff --git a/src/main/java/com/github/f4b6a3/ulid/guid/GuidCreator.java b/src/main/java/com/github/f4b6a3/ulid/guid/GuidCreator.java index 90db56c..ecfe236 100644 --- a/src/main/java/com/github/f4b6a3/ulid/guid/GuidCreator.java +++ b/src/main/java/com/github/f4b6a3/ulid/guid/GuidCreator.java @@ -51,7 +51,6 @@ public class GuidCreator { protected long firstHigh; protected long previousTimestamp; - protected boolean enableOverrunException = true; protected Random random; @@ -202,10 +201,7 @@ public class GuidCreator { protected synchronized void increment() { if ((++this.low == this.firstLow) && (++this.high == this.firstHigh)) { this.reset(); - // Too many requests - if (enableOverrunException) { - throw new UlidCreatorException(OVERRUN_MESSAGE); - } + throw new UlidCreatorException(OVERRUN_MESSAGE); } } @@ -261,20 +257,6 @@ public class GuidCreator { return (T) this; } - /** - * Used to disable the overrun exception. - * - * An exception is thrown when too many requests are made within the same - * millisecond. - * - * @return {@link GuidCreator} - */ - @SuppressWarnings("unchecked") - public synchronized T withoutOverrunException() { - this.enableOverrunException = false; - return (T) this; - } - private static class SecureRandomLazyHolder { static final Random INSTANCE = new SecureRandom(); }