Skip to content

Commit 940ffd0

Browse files
authored
Avoid NPE if muzzle exception does not contain a message (#10562)
Avoid NPE if muzzle exception does not contain a message Co-authored-by: stuart.mcculloch <stuart.mcculloch@datadoghq.com>
1 parent 6b119c6 commit 940ffd0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/muzzle/ReferenceMatcher.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ private static boolean checkMatch(
116116
}
117117
return checkMatch(reference, resolution.resolve(), mismatches);
118118
} catch (final Exception e) {
119-
if (e.getMessage().startsWith("Cannot resolve type description for ")) {
119+
String message = e.getMessage();
120+
if (message != null && message.startsWith("Cannot resolve type description for ")) {
120121
// bytebuddy throws an illegal state exception with this message if it cannot resolve types
121122
// TODO: handle missing type resolutions without catching bytebuddy's exceptions
122-
final String className = e.getMessage().replace("Cannot resolve type description for ", "");
123+
final String className = message.replace("Cannot resolve type description for ", "");
123124
mismatches.add(new Mismatch.MissingClass(reference.sources, className));
124-
return false;
125125
} else {
126126
// Shouldn't happen. Fail the reference check and add a mismatch for debug logging.
127127
mismatches.add(
128128
new Mismatch.ReferenceCheckError(
129129
e, reference, null != loader ? loader.toString() : "<bootstrap>"));
130-
return false;
131130
}
131+
return false;
132132
}
133133
}
134134

0 commit comments

Comments
 (0)