Skip to content

Commit 07778c8

Browse files
committed
fix: don't trigger BuildProject init during source-string analysis
`codajv -s <source>` crashed with ExceptionInInitializerError/NPE: analyze() called BuildProject.cleanLibraryDependencies() unconditionally, and merely referencing BuildProject runs its static initializer, which resolves a gradle/maven command via new File(projectRootPom) — null in source mode. Guard the cleanup so it runs only in project mode, where dependencies are actually downloaded. Caught by the new PyPI release smoke test.
1 parent cc6b7dc commit 07778c8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/main/java/com/ibm/cldk/CodeAnalyzer.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,13 @@ private static void analyze() throws Exception {
226226
combinedJsonObject.add("call_graph", gson.toJsonTree(sdgEdges));
227227
}
228228
}
229-
// Cleanup library dependencies directory
230-
BuildProject.cleanLibraryDependencies();
229+
// Cleanup library dependencies directory. Source-string analysis (-s) never
230+
// downloads dependencies, so skip it: touching BuildProject would run its
231+
// static initializer, which resolves a build command against the (null)
232+
// project root and throws.
233+
if (sourceAnalysis == null) {
234+
BuildProject.cleanLibraryDependencies();
235+
}
231236

232237
// Convert the JavaCompilationUnit to JSON and add to consolidated json object
233238
String symbolTableJSONString = gson.toJson(symbolTable);

0 commit comments

Comments
 (0)