chore(java indexer): Handle null pointer
methodDecl.sym might be null; log if it is and avoid a NPE.
package com.google.devtools.kythe.platform.java.helpers;
+import com.google.common.flogger.FluentLogger;
import com.sun.source.tree.BlockTree;
import com.sun.source.tree.CatchTree;
import com.sun.source.tree.ClassTree;
@@ -75,6 +76,7 @@ public class BlockAnonymousSignatureGenerator
}
}
+ private static final FluentLogger logger = FluentLogger.forEnclosingClass();
private final SignatureGenerator signatureGenerator;
BlockAnonymousSignatureGenerator(SignatureGenerator signatureGenerator) {
@@ -169,6 +171,10 @@ public class BlockAnonymousSignatureGenerator
public Void visitMethod(MethodTree methodTree, BlockAnonymousData blockData) {
JCMethodDecl methodDecl = (JCMethodDecl) methodTree;
StringBuilder methodSignature = new StringBuilder();
+ if (methodDecl.sym == null) {
+ logger.atInfo().log("methodDecl symbol was null");
+ return null;
+ }
methodDecl.sym.accept(signatureGenerator, methodSignature);
return super.visitMethod(methodTree, new BlockAnonymousData(-1, 0, methodSignature.toString()));
}
