Skip to content

Callgraph not generated in Apache Solr because of a method's token range being null #48

Description

@openrefactorymunawar

We ran on Apache Solr and after running a lot of time, it failed to generate a call graph. The error we were getting were.

2025-11-14T15:30:34.1500624Z 2025-11-14 07:30:34 PST [SERVER]: Call Graph Construction Complete
2025-11-14T15:45:16.8249110Z 2025-11-14 07:45:16 PST [SERVER]: Failed to generate cg file: Cannot invoke "org.openrefactory.util.datastructure.TokenRange.getOffset()" because "methodTr" is null
2025-11-14T15:45:16.8278010Z 2025-11-14 07:45:16 PST [SERVER]: Call graph generation complete

Looking deeper, the root cause seems to be an earlier Illegal Argument Exception,

2025-11-14T15:30:02.9506291Z java.lang.IllegalArgumentException: java.util.Map.Entry<capture#16-of ?,capture#17-of ?>
2025-11-14T15:30:02.9517578Z 	at org.eclipse.jdt.core.Signature.checkNextChar(Signature.java:1036)
2025-11-14T15:30:02.9520863Z 	at org.eclipse.jdt.core.Signature.encodeTypeSignature(Signature.java:1518)
2025-11-14T15:30:02.9521975Z 	at org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(Signature.java:1106)
2025-11-14T15:30:02.9522895Z 	at org.eclipse.jdt.core.Signature.createTypeSignature(Signature.java:1304)
2025-11-14T15:30:02.9523902Z 	at org.eclipse.jdt.core.dom.VariableBinding.getUnresolvedJavaElement(VariableBinding.java:274)
2025-11-14T15:30:02.9524971Z 	at org.eclipse.jdt.core.dom.VariableBinding.getJavaElement(VariableBinding.java:161)
2025-11-14T15:30:02.9545831Z 	at org.openrefactory.util.ASTNodeUtility.getLocalVariableScope(ASTNodeUtility.java:936)
2025-11-14T15:30:02.9550685Z 	at org.openrefactory.analysis.type.TypeCalculator.getCallingContextType(TypeCalculator.java:179)
2025-11-14T15:30:02.9552327Z 	at org.openrefactory.util.CallGraphUtility.getCallingContextDeclaredTypeHashOfMethodInvocation(CallGraphUtility.java:1470)
2025-11-14T15:30:02.9553769Z 	at org.openrefactory.util.CallGraphUtility.getServicingMethodHashIndex(CallGraphUtility.java:1298)
2025-11-14T15:30:02.9555274Z 	at org.openrefactory.analysis.type.TypeCalculatorVisitor.visit(TypeCalculatorVisitor.java:547)
2025-11-14T15:30:02.9556283Z 	at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:220)
2025-11-14T15:30:02.9557052Z 	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
2025-11-14T15:30:02.9557975Z 	at org.openrefactory.analysis.type.TypeCalculator.getCallingContextType(TypeCalculator.java:177)
2025-11-14T15:30:02.9559391Z 	at org.openrefactory.util.CallGraphUtility.getCallingContextDeclaredTypeHashOfMethodInvocation(CallGraphUtility.java:1470)
2025-11-14T15:30:02.9560830Z 	at org.openrefactory.util.CallGraphUtility.getServicingMethodHashIndex(CallGraphUtility.java:1298)
2025-11-14T15:30:02.9562161Z 	at org.openrefactory.analysis.type.TypeCalculatorVisitor.visit(TypeCalculatorVisitor.java:547)
2025-11-14T15:30:02.9563150Z 	at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:220)
2025-11-14T15:30:02.9563911Z 	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:3312)
...
...

This is perhaps the reason why the methodTr was set to null.

We should do two things.

  1. Fix the root cause (the Illegal Argument Exception)
  2. Add a defensive check in the callgraph rendering part so that such failures do not cause the entire call graph generation to fail.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions