Skip to content

Commit 231578e

Browse files
authored
fix NullPointerException in SymbolExtractor (#10858)
fix NullPointerException in SymbolExtractor getting lines from label with monotonicLineMap raise NPE if labels are not found. Handle that case to avoid NullPointerException aborting the extraction process Co-authored-by: jean-philippe.bempel <jean-philippe.bempel@datadoghq.com>
1 parent 95b7859 commit 231578e

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/symbol/SymbolExtractor.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,24 @@ private static void extractScopesFromVariables(
390390
List<Symbol> varSymbols = new ArrayList<>();
391391
int minLine = Integer.MAX_VALUE;
392392
for (LocalVariableNode var : entry.getValue()) {
393-
int line = monotonicLineMap.get(var.start.getLabel());
393+
Integer line = monotonicLineMap.get(var.start.getLabel());
394+
if (line == null) {
395+
LOGGER.debug(
396+
"Cannot find the line for variable {} idx={} in local variables",
397+
var.name,
398+
var.index);
399+
continue;
400+
}
394401
minLine = Math.min(line, minLine);
395402
varSymbols.add(
396403
new Symbol(
397404
SymbolType.LOCAL, var.name, line, Type.getType(var.desc).getClassName(), null));
398405
}
399-
int endLine = monotonicLineMap.get(entry.getKey().getLabel());
406+
Integer endLine = monotonicLineMap.get(entry.getKey().getLabel());
407+
if (endLine == null) {
408+
LOGGER.debug("Cannot find the line from end label");
409+
continue;
410+
}
400411
Scope varScope =
401412
Scope.builder(ScopeType.LOCAL, sourceFile, minLine, endLine)
402413
.symbols(varSymbols)

0 commit comments

Comments
 (0)