Skip to content

Commit

Permalink
Prevent NPE on failed bytecode lookup
Browse files Browse the repository at this point in the history
Log a warning if ClassGraph is not able to load the bytecode of the
requested class.
  • Loading branch information
bertschneider committed Jun 12, 2023
1 parent aaae641 commit 1d6c29c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ class RuntimeInstrumentor(
.acceptClasses(className)
.scan()
.use {
it.getClassInfo(className).resource.load()
it.getClassInfo(className)?.resource?.load() ?: run {
Log.warn("Failed to load bytecode of class $className")
return null
}
}
val (instrumentedBytecode, duration) = measureTimedValue {
try {
Expand Down

0 comments on commit 1d6c29c

Please sign in to comment.