Skip to content

Commit 26bee84

Browse files
authored
Fix considering directory as jar file (#7459)
In some cases, extracted jar path from the CodeSource of a class can point to a directory instead of a jar file. Now we are skipping this case to avoid having an exception trying to open it as a jar file
1 parent 529f893 commit 26bee84

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import datadog.trace.util.Strings;
1414
import java.io.ByteArrayInputStream;
1515
import java.io.ByteArrayOutputStream;
16+
import java.io.File;
1617
import java.io.IOException;
1718
import java.io.InputStream;
1819
import java.lang.instrument.Instrumentation;
@@ -160,11 +161,16 @@ private void extractSymbolForLoadedClasses() {
160161
if (!Files.exists(jarPath)) {
161162
continue;
162163
}
164+
File jarPathFile = jarPath.toFile();
165+
if (jarPathFile.isDirectory()) {
166+
// we are not supporting class directories (classpath) but only jar files
167+
continue;
168+
}
163169
if (alreadyScannedJars.contains(jarPath.toString())) {
164170
continue;
165171
}
166172
try {
167-
try (JarFile jarFile = new JarFile(jarPath.toFile())) {
173+
try (JarFile jarFile = new JarFile(jarPathFile)) {
168174
jarFile.stream()
169175
.filter(jarEntry -> jarEntry.getName().endsWith(".class"))
170176
.filter(

0 commit comments

Comments
 (0)