Skip to content

Commit 5267d28

Browse files
authored
ServiceException uses psuedorandom error instance UUIDs (#1158)
ServiceException uses psuedorandom error instance UUIDs
1 parent 9c91ef3 commit 5267d28

File tree

5 files changed

+22
-12
lines changed

5 files changed

+22
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type: improvement
2+
improvement:
3+
description: ServiceException uses psuedorandom error instance UUIDs
4+
links:
5+
- https://github.com/palantir/conjure-java-runtime-api/pull/1158

errors/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ apply plugin: 'com.palantir.revapi'
55

66
dependencies {
77
annotationProcessor "org.immutables:value"
8-
8+
99
compileOnlyApi 'org.immutables:value::annotations'
10-
10+
1111
api "com.fasterxml.jackson.core:jackson-databind"
1212
api "com.google.code.findbugs:jsr305"
1313
api "com.palantir.safe-logging:safe-logging"
1414
api "org.jetbrains:annotations"
15-
15+
1616
implementation "com.palantir.safe-logging:preconditions"
17+
implementation "com.palantir.tritium:tritium-ids"
1718

1819
testImplementation project(":extras:jackson-support")
1920
testImplementation "com.palantir.safe-logging:preconditions-assertj"

errors/src/main/java/com/palantir/conjure/java/api/errors/ServiceException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import com.palantir.logsafe.Arg;
2020
import com.palantir.logsafe.SafeLoggable;
21+
import com.palantir.tritium.ids.UniqueIds;
2122
import java.util.ArrayList;
2223
import java.util.Collections;
2324
import java.util.IdentityHashMap;
2425
import java.util.List;
2526
import java.util.Set;
26-
import java.util.UUID;
2727
import javax.annotation.Nullable;
2828

2929
/** A {@link ServiceException} thrown in server-side code to indicate server-side {@link ErrorType error states}. */
@@ -150,7 +150,8 @@ private static String generateErrorInstanceId(
150150
// Guard against cause cycles, see Throwable.printStackTrace(PrintStreamOrWriter)
151151
Set<Throwable> dejaVu) {
152152
if (cause == null || !dejaVu.add(cause)) {
153-
return UUID.randomUUID().toString();
153+
// we don't need cryptographically secure random UUIDs
154+
return UniqueIds.pseudoRandomUuidV4().toString();
154155
}
155156
if (cause instanceof ServiceException) {
156157
return ((ServiceException) cause).getErrorInstanceId();

versions.lock

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,22 @@ com.fasterxml.jackson.datatype:jackson-datatype-guava:2.16.1 (1 constraints: 3c0
77
com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.16.1 (1 constraints: 3c05423b)
88
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1 (1 constraints: 3c05423b)
99
com.google.code.findbugs:jsr305:3.0.2 (2 constraints: 1d0fb186)
10-
com.google.errorprone:error_prone_annotations:2.23.0 (5 constraints: 6649c862)
11-
com.google.guava:guava:25.1-jre (1 constraints: b117853a)
12-
com.google.j2objc:j2objc-annotations:1.1 (1 constraints: b609eba0)
13-
com.palantir.safe-logging:logger:3.7.0 (2 constraints: e1125a37)
10+
com.google.errorprone:error_prone_annotations:2.26.1 (5 constraints: 9b497093)
11+
com.google.guava:failureaccess:1.0.2 (1 constraints: 150ae2b4)
12+
com.google.guava:guava:33.1.0-jre (2 constraints: a627a813)
13+
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava (1 constraints: bd17c918)
14+
com.google.j2objc:j2objc-annotations:3.0.0 (1 constraints: 150aeab4)
15+
com.palantir.safe-logging:logger:3.7.0 (3 constraints: 3b21bf88)
1416
com.palantir.safe-logging:logger-slf4j:3.7.0 (1 constraints: 050e6842)
1517
com.palantir.safe-logging:logger-spi:3.7.0 (2 constraints: 191ea27b)
16-
com.palantir.safe-logging:preconditions:3.7.0 (3 constraints: 0f2749de)
18+
com.palantir.safe-logging:preconditions:3.7.0 (4 constraints: 6935486b)
1719
com.palantir.safe-logging:safe-logging:3.7.0 (5 constraints: c0471e0e)
1820
com.palantir.tokens:auth-tokens:3.18.0 (1 constraints: 3e054d3b)
21+
com.palantir.tritium:tritium-ids:0.87.0 (1 constraints: 4105543b)
1922
net.bytebuddy:byte-buddy:1.14.12 (2 constraints: f016bb66)
2023
net.bytebuddy:byte-buddy-agent:1.14.12 (1 constraints: 730bb2e9)
2124
org.assertj:assertj-core:3.25.3 (2 constraints: 9e19a0df)
22-
org.checkerframework:checker-qual:2.0.0 (1 constraints: 140ae5b4)
23-
org.codehaus.mojo:animal-sniffer-annotations:1.14 (1 constraints: ea09d5aa)
25+
org.checkerframework:checker-qual:3.42.0 (1 constraints: 4b0a47bf)
2426
org.immutables:value:2.10.1 (1 constraints: 3605303b)
2527
org.jetbrains:annotations:24.1.0 (1 constraints: 331166d1)
2628
org.mockito:mockito-core:5.11.0 (1 constraints: 3905443b)

versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ com.fasterxml.jackson.core:jackson-databind = 2.16.1
33
com.google.code.findbugs:jsr305 = 3.0.2
44
com.palantir.safe-logging:* = 3.7.0
55
com.palantir.tokens:auth-tokens = 3.18.0
6+
com.palantir.tritium:* = 0.87.0
67
org.apache.commons:commons-lang3 = 3.14.0
78
org.assertj:assertj-core = 3.25.3
89
org.immutables:* = 2.10.1

0 commit comments

Comments
 (0)