]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7153 Allow to override sonar.language with blank value
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 15 Mar 2016 15:02:45 +0000 (16:02 +0100)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 15 Mar 2016 15:40:24 +0000 (16:40 +0100)
sonar-batch/src/main/java/org/sonar/batch/phases/ProjectInitializer.java

index 59226eb9ff0a845eee4aa49b1884c201921f251d..8dac11520e520b9aa9749ad813681467e6a8bb38 100644 (file)
 package org.sonar.batch.phases;
 
 import org.sonar.api.batch.BatchSide;
+import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.config.Settings;
 import org.sonar.api.resources.Language;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.resources.Project;
-import org.sonar.api.utils.SonarException;
+import org.sonar.api.utils.MessageException;
 
 /**
  * Should be dropped when org.sonar.api.resources.Project is fully refactored.
@@ -49,10 +50,10 @@ public class ProjectInitializer {
 
   private void initDeprecatedLanguage(Project project) {
     String languageKey = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY);
-    if (languageKey != null) {
+    if (StringUtils.isNotBlank(languageKey)) {
       Language language = languages.get(languageKey);
       if (language == null) {
-        throw new SonarException("Language with key '" + languageKey + "' not found");
+        throw MessageException.of("Language with key '" + languageKey + "' not found");
       }
       project.setLanguage(language);
     } else {