]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5827 Fix NPE for languages with no source colorizer
authorJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Nov 2014 16:13:41 +0000 (17:13 +0100)
committerJulien HENRY <julien.henry@sonarsource.com>
Fri, 21 Nov 2014 16:13:41 +0000 (17:13 +0100)
sonar-batch/src/main/java/org/sonar/batch/source/CodeColorizers.java

index a1d3ce9c572752872028f59d8d8e5b245667db45..1bc0f315b6f2be608a9996c99a55674f1b9e34a2 100644 (file)
@@ -29,6 +29,8 @@ import org.sonar.api.web.CodeColorizerFormat;
 import org.sonar.batch.highlighting.SyntaxHighlightingData;
 import org.sonar.colorizer.Tokenizer;
 
+import javax.annotation.CheckForNull;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
@@ -63,11 +65,12 @@ public class CodeColorizers implements BatchComponent {
     this(Lists.<CodeColorizerFormat>newArrayList());
   }
 
+  @CheckForNull
   public SyntaxHighlightingData toSyntaxHighlighting(File file, String encoding, String language) {
     CodeColorizerFormat format = byLang.get(language);
     List<Tokenizer> tokenizers;
     if (format == null) {
-      tokenizers = null;
+      return null;
     } else {
       tokenizers = format.getTokenizers();
     }