Skip to content

Commit d04b08c

Browse files
author
Matt
committed
Handle long decoding by adding expected 0x prefix
1 parent 0639e03 commit d04b08c

File tree

1 file changed

+5
-2
lines changed
  • dd-java-agent/agent-profiling/profiling-controller-openjdk/src/main/java/com/datadog/profiling/controller/openjdk/events

1 file changed

+5
-2
lines changed

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/main/java/com/datadog/profiling/controller/openjdk/events/SmapEntryFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ private static HashMap<Long, String> getAnnotatedRegions() {
130130
}
131131
}
132132

133-
@SuppressForbidden // split with one-char String use a fast-path without regex usage
134133
static List<? extends Event> collectEvents() {
135134
if (!SMAP_ENTRY_EVENT.isEnabled()) {
136135
return Collections.emptyList();
@@ -188,6 +187,7 @@ static List<? extends Event> collectEvents() {
188187
buffer.append(chars[i]);
189188
i++;
190189
}
190+
buffer.insert(0, new char[] {'0', 'x'});
191191
startAddress = Long.decode(buffer.toString());
192192
buffer.setLength(0);
193193
i++;
@@ -197,6 +197,7 @@ static List<? extends Event> collectEvents() {
197197
buffer.append(chars[i]);
198198
i++;
199199
}
200+
buffer.insert(0, new char[] {'0', 'x'});
200201
endAddress = Long.decode(buffer.toString());
201202
buffer.setLength(0);
202203
i++;
@@ -216,7 +217,8 @@ static List<? extends Event> collectEvents() {
216217
buffer.append(chars[i]);
217218
i++;
218219
}
219-
offset = Long.decode("0x" + buffer.toString());
220+
buffer.insert(0, new char[] {'0', 'x'});
221+
offset = Long.decode(buffer.toString());
220222
buffer.setLength(0);
221223
i++;
222224

@@ -403,6 +405,7 @@ static List<? extends Event> collectEvents() {
403405
} catch (FileNotFoundException e) {
404406
return List.of(new SmapParseErrorEvent(ErrorReason.SMAP_FILE_NOT_FOUND));
405407
} catch (Exception e) {
408+
e.printStackTrace();
406409
return List.of(new SmapParseErrorEvent(ErrorReason.SMAP_PARSING_ERROR));
407410
}
408411
}

0 commit comments

Comments
 (0)