Skip to content

Commit 0e505e4

Browse files
authored
fix: avoid eager string alloc in setContextAttributesByIdAndBytes validation (#606)
1 parent 1bc0fb4 commit 0e505e4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ddprof-lib/src/main/java/com/datadoghq/profiler/ThreadContext.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,10 @@ public boolean setContextAttributesByIdAndBytes(int[] constantIds, byte[][] utf8
385385
// the record detached (valid=0) after an exception unwinds past attach().
386386
for (int i = 0; i < len; i++) {
387387
if (constantIds[i] > 0) {
388-
byte[] bytes = Objects.requireNonNull(utf8[i], "utf8[" + i + "]");
389-
if (bytes.length > MAX_VALUE_BYTES) {
388+
if (utf8[i] == null) {
389+
throw new NullPointerException("utf8[" + i + "]");
390+
}
391+
if (utf8[i].length > MAX_VALUE_BYTES) {
390392
throw new IllegalArgumentException("utf8[" + i + "].length exceeds MAX_VALUE_BYTES");
391393
}
392394
}

0 commit comments

Comments
 (0)