Skip to content

Commit 3656177

Browse files
committed
include the message in exception hash for symmetry with equals()
another test case for jacoco
1 parent 7381c04 commit 3656177

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

dd-java-agent/agent-debugger/debugger-el/src/main/java/com/datadog/debugger/el/EvaluationException.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ public final boolean equals(Object o) {
2626
}
2727

2828
EvaluationException that = (EvaluationException) o;
29-
return Objects.equals(getMessage(), that.getMessage())
30-
&& Objects.equals(getExpr(), that.getExpr());
29+
return Objects.equals(getExpr(), that.getExpr())
30+
&& Objects.equals(getMessage(), that.getMessage());
3131
}
3232

3333
@Override
3434
public int hashCode() {
35-
return Objects.hashCode(getExpr());
35+
int result = Objects.hashCode(getExpr());
36+
result = 31 * result + Objects.hashCode(getMessage());
37+
return result;
3638
}
3739
}

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/trigger/TriggerProbeTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,27 @@ public void sampling() throws IOException, URISyntaxException {
234234
ProbeRateLimiter.setSamplerSupplier(null);
235235
}
236236
}
237+
238+
@Test
239+
public void noSampling() throws IOException, URISyntaxException {
240+
try {
241+
MockSampler sampler = new MockSampler();
242+
ProbeRateLimiter.setSamplerSupplier(value -> sampler);
243+
244+
final String className = "com.datadog.debugger.TriggerProbe01";
245+
TriggerProbe probe1 =
246+
createTriggerProbe(
247+
TRIGGER_PROBE_ID1, TRIGGER_PROBE_SESSION_ID, className, "entry", "()", null, null);
248+
Configuration config = Configuration.builder().setService(SERVICE_NAME).add(probe1).build();
249+
installProbes(config);
250+
Class<?> testClass = compileAndLoadClass(className);
251+
for (int i = 0; i < 100; i++) {
252+
Reflect.onClass(testClass).call("main", "").get();
253+
}
254+
255+
assertTrue(sampler.getCallCount() != 0);
256+
} finally {
257+
ProbeRateLimiter.setSamplerSupplier(null);
258+
}
259+
}
237260
}

0 commit comments

Comments
 (0)