Skip to content

Commit f190b2e

Browse files
committed
Avoid UUID.randomUUID() in startup code
This is done because bootstrapping the plumbing needed by the JDK to produce a UUID value is expensive, it thus doesn't make sense to pay this cost when the property isn't actually needed
1 parent 35444ab commit f190b2e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

vertx-core/src/main/java/io/vertx/core/file/impl/FileCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static File setupCacheDir(String fileCacheDir) {
4545

4646
// the cacheDir will be suffixed a unique id to avoid eavesdropping from other processes/users
4747
// also this ensures that if process A deletes cacheDir, it won't affect process B
48-
String cacheDirName = fileCacheDir + "-" + UUID.randomUUID();
48+
String cacheDirName = fileCacheDir + "-" + System.nanoTime();
4949
File cacheDir = new File(cacheDirName);
5050
// Create the cache directory
5151
try {

vertx-core/src/main/java/io/vertx/core/impl/deployment/DefaultDeploymentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public DefaultDeploymentManager(VertxImpl vertx) {
3636
}
3737

3838
private String generateDeploymentID() {
39-
return UUID.randomUUID().toString();
39+
return Long.valueOf(System.nanoTime()).toString();
4040
}
4141

4242
public Future<Void> undeploy(String deploymentID) {

vertx-core/src/test/java/io/vertx/tests/file/FileResolverTestBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,12 @@ public void testGetTheCacheDirWithoutHacks() {
477477
if (cacheDir != null) {
478478
assertTrue(cacheDir.startsWith(cacheBaseDir + "-"));
479479
// strip the remaining
480-
String uuid = cacheDir.substring(cacheBaseDir.length() + 1);
480+
String val = cacheDir.substring(cacheBaseDir.length() + 1);
481481
try {
482-
UUID.fromString(uuid);
482+
Long.parseLong(val);
483483
// OK
484484
} catch (Exception e) {
485-
fail("Expected a UUID");
485+
fail("Expected a Long");
486486
}
487487
}
488488
}

0 commit comments

Comments
 (0)