diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-19 15:42:35 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-19 18:37:48 +0400 |
commit | 84d96bf6ada999fe22db0551b3e9d56f6605c9bd (patch) | |
tree | b72b573544dde100e57ed0d9c7aa885558c94926 /plugins/sonar-findbugs-plugin/src | |
parent | eab39610634208cbfd9f84c03ce3204bbbd66685 (diff) | |
download | sonarqube-84d96bf6ada999fe22db0551b3e9d56f6605c9bd.tar.gz sonarqube-84d96bf6ada999fe22db0551b3e9d56f6605c9bd.zip |
SONAR-2594 FindBugs plugin should support localized violations
Diffstat (limited to 'plugins/sonar-findbugs-plugin/src')
2 files changed, 11 insertions, 0 deletions
diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java index 21057ea4663..9526f7975c2 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsConfiguration.java @@ -35,6 +35,7 @@ import org.sonar.plugins.findbugs.xml.Match; import java.io.*; import java.util.ArrayList; import java.util.List; +import java.util.Locale; /** * @since 2.4 @@ -121,6 +122,10 @@ public class FindbugsConfiguration implements BatchExtension { return project.getConfiguration().getLong(CoreProperties.FINDBUGS_TIMEOUT_PROPERTY, CoreProperties.FINDBUGS_TIMEOUT_DEFAULT_VALUE); } + public Locale getLocale() { + return new Locale(project.getConfiguration().getString(CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY, CoreProperties.CORE_VIOLATION_LOCALE_DEFAULT_VALUE)); + } + private File jsr305Lib; private File annotationsLib; diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java index 6beceb7badc..cd0d1fb175a 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java @@ -41,6 +41,7 @@ import java.lang.reflect.Field; import java.net.URL; import java.util.Enumeration; import java.util.List; +import java.util.Locale; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -64,6 +65,10 @@ public class FindbugsExecutor implements BatchExtension { ClassLoader initialClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(FindBugs2.class.getClassLoader()); + // This is a dirty workaround, but unfortunately there is no other way to specify locale for FindBugs - see SONAR-2594 + Locale initialLocale = Locale.getDefault(); + Locale.setDefault(configuration.getLocale()); + OutputStream xmlOutput = null; ExecutorService executorService = Executors.newSingleThreadExecutor(); try { @@ -122,6 +127,7 @@ public class FindbugsExecutor implements BatchExtension { executorService.shutdown(); IOUtils.closeQuietly(xmlOutput); Thread.currentThread().setContextClassLoader(initialClassLoader); + Locale.setDefault(initialLocale); } } |