diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-03-28 16:15:09 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-03-28 16:15:09 +0200 |
commit | 8d37f9e041532f1feb6c9658c7cc50d6bce1a604 (patch) | |
tree | 89cfd9aae09d6321dd0c7fa0dd6f9cb2dcb3e579 /sonar-plugin-api | |
parent | c9846f5d48118eca3273de2cf065bd007f5dff45 (diff) | |
download | sonarqube-8d37f9e041532f1feb6c9658c7cc50d6bce1a604.tar.gz sonarqube-8d37f9e041532f1feb6c9658c7cc50d6bce1a604.zip |
Fix Quality flaws
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 8 insertions, 3 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java index 130b07ac83e..c5afc2a36b1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/AesCipher.java @@ -37,6 +37,8 @@ import java.nio.charset.StandardCharsets; import java.security.Key; import java.security.SecureRandom; +import static java.nio.charset.StandardCharsets.UTF_8; + final class AesCipher implements Cipher { // Can't be increased because of Java 6 policy files : @@ -101,7 +103,7 @@ final class AesCipher implements Cipher { if (!file.exists() || !file.isFile()) { throw new IllegalStateException("The property " + CoreProperties.ENCRYPTION_SECRET_KEY_PATH + " does not link to a valid file: " + path); } - String s = FileUtils.readFileToString(file); + String s = FileUtils.readFileToString(file, UTF_8); if (StringUtils.isBlank(s)) { throw new IllegalStateException("No secret key in the file: " + path); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java index 1b316b0c20b..0e10bdb7d25 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/rule/RulesDefinition.java @@ -52,6 +52,7 @@ import org.sonarsource.api.sonarlint.SonarLintSide; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; import static java.lang.String.format; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.commons.lang.StringUtils.trimToNull; /** @@ -751,7 +752,7 @@ public interface RulesDefinition { public NewRule setHtmlDescription(@Nullable URL classpathUrl) { if (classpathUrl != null) { try { - setHtmlDescription(IOUtils.toString(classpathUrl)); + setHtmlDescription(IOUtils.toString(classpathUrl, UTF_8)); } catch (IOException e) { throw new IllegalStateException("Fail to read: " + classpathUrl, e); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java index efdcfc93cd8..018ab9580fd 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/AbstractRubyTemplate.java @@ -27,6 +27,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.sonar.api.utils.SonarException; +import static java.nio.charset.StandardCharsets.UTF_8; + /** * @since 1.11 * @deprecated since 6.3. This class is ignored. @@ -56,7 +58,7 @@ public abstract class AbstractRubyTemplate { File file = new File(getTemplatePath()); if (file.exists()) { // the result is not cached - return FileUtils.readFileToString(file); + return FileUtils.readFileToString(file, UTF_8); } throw new FileNotFoundException(getTemplatePath()); } |