Skip to content

Commit d136bce

Browse files
committed
rename + add throw exception
1 parent 2b669c3 commit d136bce

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/agent/DebuggerTransformer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private Map<Where, List<ProbeDefinition>> mergeLocations(
202202
Where where = definition.getWhere();
203203
if (definition instanceof ExceptionProbe) {
204204
// normalize where for line => to precise method location
205-
where = Where.from(definition.getWhere(), classFileLines);
205+
where = Where.convertLineToMethod(definition.getWhere(), classFileLines);
206206
}
207207
List<ProbeDefinition> instrumentationDefinitions =
208208
mergedProbes.computeIfAbsent(where, key -> new ArrayList<>());

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/exception/ExceptionProbeManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void createProbesForException(String fingerprint, StackTraceElement[] sta
3535
continue;
3636
}
3737
Where where =
38-
Where.from(
38+
Where.convertLineToMethod(
3939
stackTraceElement.getClassName(),
4040
stackTraceElement.getMethodName(),
4141
null,

‎dd-java-agent/agent-debugger/src/main/java/com/datadog/debugger/probe/Where.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ public class Where {
4141
this(typeName, methodName, signature, sourceLines(lines), sourceFile);
4242
}
4343

44-
public static Where from(String typeName, String methodName, String signature, String... lines) {
44+
public static Where convertLineToMethod(
45+
String typeName, String methodName, String signature, String... lines) {
4546
return new Where(typeName, methodName, signature, lines, null);
4647
}
4748

48-
public static Where from(String sourceFile, int line) {
49+
public static Where convertLineToMethod(String sourceFile, int line) {
4950
return new Where(null, null, null, new SourceLine[] {new SourceLine(line)}, sourceFile);
5051
}
5152

@@ -60,12 +61,12 @@ protected static SourceLine[] sourceLines(String[] defs) {
6061
return lines;
6162
}
6263

63-
public static Where from(Where lineWhere, ClassFileLines classFileLines) {
64+
public static Where convertLineToMethod(Where lineWhere, ClassFileLines classFileLines) {
6465
if (lineWhere.methodName != null && lineWhere.lines != null) {
6566
MethodNode method = classFileLines.getMethodByLine(lineWhere.lines[0].getFrom());
6667
return new Where(lineWhere.typeName, method.name, method.desc, (SourceLine[]) null, null);
6768
}
68-
return lineWhere;
69+
throw new IllegalArgumentException("Invalid where to convert from line to method " + lineWhere);
6970
}
7071

7172
public String getTypeName() {

‎dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturedSnapshotTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2067,7 +2067,7 @@ public void lineRecord() throws IOException, URISyntaxException {
20672067
public void allProbesSameMethod() throws IOException, URISyntaxException {
20682068
final String CLASS_NAME = "CapturedSnapshot01";
20692069
final String METRIC_NAME = "count";
2070-
Where where = Where.from(CLASS_NAME, "main", null);
2070+
Where where = Where.convertLineToMethod(CLASS_NAME, "main", null);
20712071
Configuration configuration =
20722072
Configuration.builder()
20732073
.add(

‎dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/DebuggerTransformerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ <T extends ProbeDefinition> T createMock(
380380
.when(mock)
381381
.instrument(any(), anyList(), anyList());
382382
when(mock.getProbeId()).thenReturn(new ProbeId(id, 0));
383-
Where where = Where.from(ArrayList.class.getName(), "add", "(Object)");
383+
Where where = Where.convertLineToMethod(ArrayList.class.getName(), "add", "(Object)");
384384
when(mock.getWhere()).thenReturn(where);
385385
return (T) mock;
386386
}

0 commit comments

Comments
 (0)