Skip to content

Commit

Permalink
Merge pull request quarkusio#45610 from geoand/remove-uuid
Browse files Browse the repository at this point in the history
Remove the use of UUID in startup code
  • Loading branch information
geoand authored Jan 15, 2025
2 parents 919ab53 + 713ccf8 commit c531460
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class QuarkusErrorHandler implements Handler<RoutingContext> {
* we don't want to generate a new UUID each time as it is slowish. Instead, we just generate one based one
* and then use a counter.
*/
private static final String BASE_ID = UUID.randomUUID() + "-";

private static final AtomicLong ERROR_COUNT = new AtomicLong();

Expand Down Expand Up @@ -148,7 +147,7 @@ public void accept(Throwable throwable) {
event.response().setStatusCode(event.statusCode() > 0 ? event.statusCode() : 500);
}

String uuid = BASE_ID + ERROR_COUNT.incrementAndGet();
String uuid = LazyHolder.BASE_ID + ERROR_COUNT.incrementAndGet();
String details;
String stack = "";
Throwable exception = event.failure();
Expand Down Expand Up @@ -427,4 +426,8 @@ static String pickFirstSupportedAndAcceptedContentType(RoutingContext context) {
}
}
}

private static class LazyHolder {
private static final String BASE_ID = UUID.randomUUID() + "-";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -395,8 +395,7 @@ public void run() {
}

private static File getRandomDirectory(File tmp) {
long random = Math.abs(UUID.randomUUID().getMostSignificantBits());
File cache = new File(tmp, Long.toString(random));
File cache = new File(tmp, Long.toString(new Random().nextLong()));
if (cache.isDirectory()) {
// Do not reuse an existing directory.
return getRandomDirectory(tmp);
Expand Down

0 comments on commit c531460

Please sign in to comment.