]> source.dussan.org Git - sonarqube.git/commitdiff
Use StandardCharsets instead of Guava and commons-io
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 15 May 2015 11:54:44 +0000 (13:54 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 15 May 2015 11:54:54 +0000 (13:54 +0200)
52 files changed:
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/scm/XooBlameCommand.java
server/sonar-process-monitor/src/main/java/org/sonar/process/monitor/StreamGobbler.java
server/sonar-process/src/main/java/org/sonar/process/AesCipher.java
server/sonar-process/src/main/java/org/sonar/process/Base64Cipher.java
server/sonar-process/src/main/java/org/sonar/process/ConfigurationUtils.java
server/sonar-server/src/main/java/org/sonar/server/activity/index/ActivityResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/computation/source/ComputeFileSourceData.java
server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FeedFileSources.java
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/FileSourceDto.java
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelPluginRepository.java
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelXMLExporter.java
server/sonar-server/src/main/java/org/sonar/server/measure/MeasureFilter.java
server/sonar-server/src/main/java/org/sonar/server/platform/ServerImpl.java
server/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileCopier.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileExporters.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileBackupAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileRestoreAction.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/CreateAction.java
server/sonar-server/src/main/java/org/sonar/server/source/index/SourceLineResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/source/ws/HashAction.java
server/sonar-server/src/main/java/org/sonar/server/source/ws/RawAction.java
server/sonar-server/src/main/java/org/sonar/server/startup/GeneratePluginIndex.java
server/sonar-server/src/main/java/org/sonar/server/test/index/TestResultSetIterator.java
server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
server/sonar-server/src/main/java/org/sonar/server/ws/ServletResponse.java
server/sonar-server/src/main/java/org/sonar/server/ws/WebServiceEngine.java
server/sonar-server/src/test/java/org/sonar/server/db/migrations/v50/FeedFileSourcesTest.java
server/sonar-server/src/test/java/org/sonar/server/debt/DebtCharacteristicsXMLImporterTest.java
server/sonar-server/src/test/java/org/sonar/server/debt/DebtModelXMLExporterTest.java
server/sonar-server/src/test/java/org/sonar/server/debt/DebtRulesXMLImporterTest.java
server/sonar-server/src/test/java/org/sonar/server/duplication/ws/DuplicationsParserTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/IssueChangesEmailTemplateTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/MyNewIssuesEmailTemplateTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/notification/NewIssuesEmailTemplateTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterClientTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackuperMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/startup/JdbcDriverDeployerTest.java
server/sonar-server/src/test/java/org/sonar/server/ws/WsTester.java
sonar-application/src/main/java/org/sonar/application/PropsBuilder.java
sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java
sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java
sonar-core/src/main/java/org/sonar/core/graph/graphson/GraphsonUtil.java
sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDto.java
sonar-core/src/main/java/org/sonar/core/util/DefaultHttpDownloader.java
sonar-core/src/test/java/org/sonar/core/util/DefaultHttpDownloaderTest.java
sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java
sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java
sonar-testing-harness/src/main/java/org/sonar/test/JsonAssert.java
sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java

index 0d1c978e0de86bab3aa284171db6abfea235b8bb..dcf5258413b2932a77e37460900e22beea0e8c1d 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.xoo.scm;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.batch.fs.InputFile;
@@ -30,6 +29,7 @@ import org.sonar.api.utils.DateUtils;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -53,7 +53,7 @@ public class XooBlameCommand extends BlameCommand {
     }
 
     try {
-      List<String> lines = FileUtils.readLines(scmDataFile, Charsets.UTF_8.name());
+      List<String> lines = FileUtils.readLines(scmDataFile, StandardCharsets.UTF_8);
       List<BlameLine> blame = new ArrayList<>(lines.size());
       int lineNumber = 0;
       for (String line : lines) {
index 35c03564abf19c06506a286f61c8aa1573e6c0cf..73181e148a3e781368ef17c243aab6a902415c16 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.process.monitor;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,6 +28,7 @@ import javax.annotation.Nullable;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 
 /**
  * Reads process output and writes to logs
@@ -50,7 +50,7 @@ class StreamGobbler extends Thread {
 
   @Override
   public void run() {
-    BufferedReader br = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
+    BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
     try {
       String line;
       while ((line = br.readLine()) != null) {
index f98f1fe65ddbccb5604f3b1df5dc73261a26834c..7759e1ab2fa657c75a3f0c48ebe54e7424a571ea 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.sonar.process;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
@@ -32,6 +31,7 @@ import javax.crypto.spec.SecretKeySpec;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.security.Key;
 import java.security.SecureRandom;
 
@@ -74,7 +74,7 @@ final class AesCipher implements Cipher {
       javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance(CRYPTO_KEY);
       cipher.init(javax.crypto.Cipher.DECRYPT_MODE, loadSecretFile());
       byte[] cipherData = cipher.doFinal(Base64.decodeBase64(StringUtils.trim(encryptedText)));
-      return new String(cipherData, Charsets.UTF_8);
+      return new String(cipherData, StandardCharsets.UTF_8);
     } catch (RuntimeException e) {
       throw e;
     } catch (Exception e) {
index ca9044850e91b0e49b182a55afb95caa77a821df..209588e2d906170e1820ee881dfaddf6f02ef8f5 100644 (file)
 package org.sonar.process;
 
 import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.Charsets;
+
+import java.nio.charset.StandardCharsets;
 
 final class Base64Cipher implements Cipher {
   @Override
   public String encrypt(String clearText) {
-    return Base64.encodeBase64String(clearText.getBytes(Charsets.UTF_8));
+    return Base64.encodeBase64String(clearText.getBytes(StandardCharsets.UTF_8));
   }
 
   @Override
   public String decrypt(String encryptedText) {
-    return new String(Base64.decodeBase64(encryptedText), Charsets.UTF_8);
+    return new String(Base64.decodeBase64(encryptedText), StandardCharsets.UTF_8);
   }
 }
index 458cf0317229857c9ff362c7813390d984677931..a9e27300f1ffa34981f907ff384d48a95cd3f4e5 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.process;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.text.StrSubstitutor;
@@ -28,6 +27,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.Enumeration;
 import java.util.Map;
 import java.util.Properties;
@@ -60,7 +60,7 @@ public final class ConfigurationUtils {
     Properties properties = new Properties();
     Reader reader = null;
     try {
-      reader = new InputStreamReader(new FileInputStream(propertyFile), Charsets.UTF_8);
+      reader = new InputStreamReader(new FileInputStream(propertyFile), StandardCharsets.UTF_8);
       properties.load(reader);
     } catch (Exception e) {
       throw new IllegalStateException("Could not read properties from file: " + args[0], e);
index 430db67a0c50a67414d39b9129290a20fb14030c..df6fbf59c8a609b251658bce19fd8b67a1fbd9af 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.activity.index;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.api.utils.KeyValueFormat;
@@ -31,7 +30,12 @@ import org.sonar.server.util.DateCollector;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStreamWriter;
-import java.sql.*;
+import java.nio.charset.StandardCharsets;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
 import java.util.Date;
 
 /**
@@ -77,7 +81,7 @@ class ActivityResultSetIterator extends ResultSetIterator<UpdateRequest> {
   protected UpdateRequest read(ResultSet rs) throws SQLException {
     ByteArrayOutputStream bytes = new ByteArrayOutputStream();
     // all the fields must be present, even if value is null
-    JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, Charsets.UTF_8)).setSerializeNulls(true);
+    JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, StandardCharsets.UTF_8)).setSerializeNulls(true);
     writer.beginObject();
     String key = rs.getString(1);
     writer.prop(ActivityIndexDefinition.FIELD_KEY, key);
index 88cddc7dca4f9644d24636aaa1062144fff9af12..fd983c4278989f5534aeb14067790ab3e3debdf8 100644 (file)
@@ -29,7 +29,7 @@ import java.security.MessageDigest;
 import java.util.Iterator;
 import java.util.List;
 
-import static com.google.common.base.Charsets.UTF_8;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 public class ComputeFileSourceData {
 
index d416bb753454c81f5b91bcbacc06c4074a3c3691..78df32a46aa9816f8552e7673cf3bcaf83944bdc 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.computation.step;
 
 import com.google.common.collect.ImmutableMap;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.LineIterator;
@@ -51,6 +50,7 @@ import org.sonar.server.source.db.FileSourceDb;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -118,7 +118,7 @@ public class PersistFileSourcesStep implements ComputationStep {
 
   private static LineIterator sourceLinesIterator(File file) {
     try {
-      return IOUtils.lineIterator(FileUtils.openInputStream(file), Charsets.UTF_8);
+      return IOUtils.lineIterator(FileUtils.openInputStream(file), StandardCharsets.UTF_8);
     } catch (IOException e) {
       throw new IllegalStateException("Fail to traverse file: " + file, e);
     }
index be9751716502fd217376665e57840aeee0e0966d..d37850b339491d159dcad8cf5f5d422d5a9b1152 100644 (file)
  */
 package org.sonar.server.db.migrations.v50;
 
-import static com.google.common.base.Charsets.UTF_8;
-
-import java.sql.SQLException;
-import java.util.Date;
-
-import javax.annotation.Nullable;
-
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.Database;
@@ -35,6 +28,12 @@ import org.sonar.server.db.migrations.Select.Row;
 import org.sonar.server.db.migrations.Select.RowReader;
 import org.sonar.server.db.migrations.SqlStatement;
 
+import javax.annotation.Nullable;
+
+import java.nio.charset.StandardCharsets;
+import java.sql.SQLException;
+import java.util.Date;
+
 /**
  * Used in the Active Record Migration 714
  *
@@ -220,7 +219,7 @@ public class FeedFileSources extends BaseDataChange {
     } else {
       result = shortBytes;
     }
-    return new String(result, UTF_8);
+    return new String(result, StandardCharsets.UTF_8);
   }
 
   private final System2 system;
index 1219afd4d924cfbc803c52723c9c659da84db186..f3ca467ee98ba0f293f49c51aa9168a5b9947bd0 100644 (file)
  */
 package org.sonar.server.db.migrations.v50;
 
-import static com.google.common.base.Charsets.UTF_8;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
+import com.google.common.base.Splitter;
+import com.google.common.collect.ImmutableList;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang.StringUtils;
 import org.codehaus.stax2.XMLInputFactory2;
@@ -43,8 +31,19 @@ import org.sonar.api.measures.CoreMetrics;
 import org.sonar.api.utils.KeyValueFormat;
 import org.sonar.api.utils.text.CsvWriter;
 
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableList;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 class FileSourceDto {
 
index 8ca78f7c3f6c44ebd25a0ff789ea5bd70cc108c5..67b016de536cc8e0467706a057aba97ad224cf0d 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.server.debt;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
-import org.apache.commons.io.Charsets;
 import org.picocontainer.Startable;
 import org.sonar.api.Plugin;
 import org.sonar.api.ServerSide;
@@ -31,6 +30,7 @@ import org.sonar.core.platform.PluginRepository;
 
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -123,7 +123,7 @@ public class DebtModelPluginRepository implements Startable {
   public Reader createReaderForXMLFile(String pluginKey) {
     ClassLoader classLoader = contributingPluginKeyToClassLoader.get(pluginKey);
     String xmlFilePath = getXMLFilePath(pluginKey);
-    return new InputStreamReader(classLoader.getResourceAsStream(xmlFilePath), Charsets.UTF_8);
+    return new InputStreamReader(classLoader.getResourceAsStream(xmlFilePath), StandardCharsets.UTF_8);
   }
 
   @VisibleForTesting
index 8dfae1f9e4d535da5f2a556942b69c05766a2d92..fc14e492886efe123078fa228647e0031a7ee5fa 100644 (file)
@@ -24,7 +24,6 @@ import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Ordering;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.ServerSide;
@@ -45,6 +44,7 @@ import javax.xml.transform.stream.StreamResult;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -170,10 +170,10 @@ public class DebtModelXMLExporter {
       serializer.setOutputProperty(OutputKeys.INDENT, "yes");
       serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
       serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", DEFAULT_INDENT);
-      Source xmlSource = new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8))));
+      Source xmlSource = new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))));
       StreamResult res = new StreamResult(new ByteArrayOutputStream());
       serializer.transform(xmlSource, res);
-      return new String(((ByteArrayOutputStream) res.getOutputStream()).toByteArray(), Charsets.UTF_8);
+      return new String(((ByteArrayOutputStream) res.getOutputStream()).toByteArray(), StandardCharsets.UTF_8);
     } catch (TransformerException ignored) {
       // Ignore, raw XML will be returned
     }
index 68c07974484ceeb49e262ab0e76af86f7c8aae45..0dd3f5182060c9de599b576637894178d0991bb1 100644 (file)
@@ -185,7 +185,7 @@ public class MeasureFilter {
 
   @VisibleForTesting
   static List<String> sanitize(@Nullable List<String> list) {
-    return isEmptyList(list) ? Collections.<String> emptyList() : Lists.newArrayList(list);
+    return isEmptyList(list) ? Collections.<String>emptyList() : Lists.newArrayList(list);
   }
 
   private static boolean isEmptyList(@Nullable List<String> list) {
index bae47f5e2fcededd7f3fb0dd23d79be7fb447902..435e3e8b21bb084306c3f7f397afc045c17f0be5 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.platform;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
 import com.google.common.base.Joiner;
 import com.google.common.io.Resources;
 import org.apache.commons.io.IOUtils;
@@ -39,6 +38,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Properties;
@@ -142,9 +142,9 @@ public final class ServerImpl extends Server implements Startable {
   private static String readVersion(String filename) throws IOException {
     URL url = ServerImpl.class.getResource(filename);
     if (url != null) {
-      String version = Resources.toString(url, Charsets.UTF_8);
+      String version = Resources.toString(url, StandardCharsets.UTF_8);
       if (!StringUtils.isBlank(version)) {
-        return  StringUtils.deleteWhitespace(version);
+        return StringUtils.deleteWhitespace(version);
       }
     }
     throw new IllegalStateException("Unknown SonarQube version");
index 0f774f15e039ac3e1006d85466becde66cd104a2..d4b3d1648901209290939beb57f1e4bedd2492a2 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.plugins;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.Properties;
 import org.sonar.api.Property;
@@ -34,6 +33,7 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer.Mode;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 
 /**
@@ -100,9 +100,9 @@ public class UpdateCenterClient {
   private UpdateCenter init() {
     InputStream input = null;
     try {
-      String content = uriReader.readString(uri, Charsets.UTF_8);
+      String content = uriReader.readString(uri, StandardCharsets.UTF_8);
       java.util.Properties properties = new java.util.Properties();
-      input = IOUtils.toInputStream(content, Charsets.UTF_8.name());
+      input = IOUtils.toInputStream(content, StandardCharsets.UTF_8);
       properties.load(input);
       return new UpdateCenterDeserializer(Mode.PROD, true).fromProperties(properties);
 
index 1c8b14cfdce58b9c64a45f76e7fb72b661119523..af91f724f54da9e3bfa3a9e4dde46c145e1e5cb3 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
@@ -35,6 +34,7 @@ import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 
 @ServerSide
 public class QProfileCopier {
@@ -100,7 +100,7 @@ public class QProfileCopier {
   private void backup(String profileKey, File backupFile) {
     Writer writer = null;
     try {
-      writer = new OutputStreamWriter(FileUtils.openOutputStream(backupFile), Charsets.UTF_8);
+      writer = new OutputStreamWriter(FileUtils.openOutputStream(backupFile), StandardCharsets.UTF_8);
       backuper.backup(profileKey, writer);
     } catch (IOException e) {
       throw new IllegalStateException("Fail to open temporary backup file: " + backupFile, e);
@@ -112,7 +112,7 @@ public class QProfileCopier {
   private void restore(File backupFile, QProfileName profileName) {
     Reader reader = null;
     try {
-      reader = new InputStreamReader(FileUtils.openInputStream(backupFile), Charsets.UTF_8);
+      reader = new InputStreamReader(FileUtils.openInputStream(backupFile), StandardCharsets.UTF_8);
       backuper.restore(reader, profileName);
     } catch (IOException e) {
       throw new IllegalStateException("Fail to create temporary backup file: " + backupFile, e);
index 4d3f4ffa20187e0a5932c9eaa2de9c91b6547333..13d9d364ac7dd0f37043572164c42c7c84edbc83 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.ServerSide;
@@ -42,6 +41,7 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -141,7 +141,7 @@ public class QProfileExporters {
   }
 
   public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, InputStream xml, DbSession dbSession) {
-    return importXml(profileDto, importerKey, new InputStreamReader(xml, Charsets.UTF_8), dbSession);
+    return importXml(profileDto, importerKey, new InputStreamReader(xml, StandardCharsets.UTF_8), dbSession);
   }
 
   public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, Reader xml, DbSession dbSession) {
index f87f637f9569383c0479303751eb42714ca757b5..0bca14c941dd4e7634c88949b6370cdd6bd1f75d 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile.ws;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.server.ws.Request;
@@ -34,6 +33,7 @@ import org.sonar.server.qualityprofile.QProfileBackuper;
 import org.sonar.server.qualityprofile.QProfileFactory;
 
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 
 public class QProfileBackupAction implements QProfileWsAction {
 
@@ -62,12 +62,11 @@ public class QProfileBackupAction implements QProfileWsAction {
     QProfileIdentificationParamUtils.defineProfileParams(backup, languages);
   }
 
-
   @Override
   public void handle(Request request, Response response) throws Exception {
     Stream stream = response.stream();
     stream.setMediaType(MimeTypes.XML);
-    OutputStreamWriter writer = new OutputStreamWriter(stream.output(), Charsets.UTF_8);
+    OutputStreamWriter writer = new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8);
     DbSession session = dbClient.openSession(false);
     try {
       String profileKey = QProfileIdentificationParamUtils.getProfileKeyFromParameters(request, profileFactory, session);
index 9efca568911f08b0624547cde994e460f69cfba8..1750393c147cbc54498d1dd3a9d1c89d861e1404 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile.ws;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.profiles.ProfileExporter;
@@ -42,6 +41,7 @@ import org.sonar.server.qualityprofile.QProfileFactory;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 public class QProfileExportAction implements QProfileWsAction {
@@ -86,8 +86,8 @@ public class QProfileExportAction implements QProfileWsAction {
       .setRequired(true);
 
     List<String> exporterKeys = Lists.newArrayList();
-    for (Language lang: languages.all()) {
-      for(ProfileExporter exporter: exporters.exportersForLanguage(lang.getKey())) {
+    for (Language lang : languages.all()) {
+      for (ProfileExporter exporter : exporters.exportersForLanguage(lang.getKey())) {
         exporterKeys.add(exporter.getKey());
       }
     }
@@ -111,10 +111,10 @@ public class QProfileExportAction implements QProfileWsAction {
     DbSession dbSession = dbClient.openSession(false);
     Stream stream = response.stream();
     OutputStream output = stream.output();
-    Writer writer = new OutputStreamWriter(output, Charsets.UTF_8);
+    Writer writer = new OutputStreamWriter(output, StandardCharsets.UTF_8);
 
     try {
-      QualityProfileDto profile = null;
+      QualityProfileDto profile;
       if (name == null) {
         profile = profileFactory.getDefault(dbSession, language);
       } else {
index 0daf91ff217690134c12ea4c825e6d77ecd9747f..621bf9473f006ff3f5f0cc06791fd0f3abe76f47 100644 (file)
  */
 package org.sonar.server.qualityprofile.ws;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Preconditions;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.resources.Languages;
 import org.sonar.api.server.ws.Request;
@@ -35,6 +32,10 @@ import org.sonar.server.qualityprofile.BulkChangeResult;
 import org.sonar.server.qualityprofile.QProfileBackuper;
 import org.sonar.server.user.UserSession;
 
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+
 public class QProfileRestoreAction implements QProfileWsAction {
 
   private static final String PARAM_BACKUP = "backup";
@@ -70,7 +71,7 @@ public class QProfileRestoreAction implements QProfileWsAction {
 
     try {
       Preconditions.checkArgument(backup != null, "A backup file must be provided");
-      reader = new InputStreamReader(backup, Charsets.UTF_8);
+      reader = new InputStreamReader(backup, StandardCharsets.UTF_8);
       BulkChangeResult result = backuper.restore(reader, null);
       writeResponse(response.newJsonWriter(), result);
     } finally {
index 43e95d449a1cbc4b639d8de2a3976bc75617009a..c97c0e06cfb0fe5cf557e9026c9380b53fd0ae6b 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.rule.ws;
 
 import com.google.common.base.Strings;
-import org.apache.commons.io.Charsets;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rule.Severity;
@@ -37,6 +36,7 @@ import org.sonar.server.rule.Rule;
 import org.sonar.server.rule.RuleService;
 
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 
 /**
  * @since 4.4
@@ -168,7 +168,7 @@ public class CreateAction implements RulesWsAction {
     Response.Stream stream = response.stream();
     stream.setStatus(409);
     stream.setMediaType(MimeTypes.JSON);
-    JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output(), Charsets.UTF_8)).beginObject().name("rule");
+    JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8)).beginObject().name("rule");
     mapping.write(rule, json, null /* TODO replace by SearchOptions immutable constant */);
     json.endObject().close();
   }
index 95561fd4c6bf1335d73a9fa8a18ea64f0dda7821..d23082d857d3ac738a269b95e1b6d49b9cedd441 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.source.index;
 
-import org.apache.commons.io.Charsets;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.core.source.db.FileSourceDto;
@@ -32,6 +31,7 @@ import javax.annotation.Nullable;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -77,7 +77,7 @@ public class SourceLineResultSetIterator extends ResultSetIterator<FileSourcesUp
       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
 
       // all the fields must be present, even if value is null
-      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, Charsets.UTF_8)).setSerializeNulls(true);
+      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, StandardCharsets.UTF_8)).setSerializeNulls(true);
       writer.beginObject();
       writer.prop(SourceLineIndexDefinition.FIELD_PROJECT_UUID, projectUuid);
       writer.prop(SourceLineIndexDefinition.FIELD_FILE_UUID, fileUuid);
index 35751b53abd24c8c60c45cfb1948eb56bb8a41a8..69cbfada5c44b5e925ee60ff3f717c65bcdf342a 100644 (file)
@@ -22,10 +22,6 @@ package org.sonar.server.source.ws;
 import com.google.common.base.Function;
 import com.google.common.io.CharStreams;
 import com.google.common.io.Resources;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import org.apache.commons.io.Charsets;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
@@ -35,6 +31,11 @@ import org.sonar.core.persistence.DbSession;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.user.UserSession;
 
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+
 public class HashAction implements SourcesWsAction {
 
   private final DbClient dbClient;
@@ -69,7 +70,7 @@ public class HashAction implements SourcesWsAction {
       userSession.checkProjectUuidPermission(UserRole.USER, component.projectUuid());
 
       response.stream().setMediaType("text/plain");
-      OutputStreamWriter writer = new OutputStreamWriter(response.stream().output(), Charsets.UTF_8);
+      OutputStreamWriter writer = new OutputStreamWriter(response.stream().output(), StandardCharsets.UTF_8);
       try {
         HashFunction hashFunction = new HashFunction(writer, componentKey);
         dbClient.fileSourceDao().readLineHashesStream(session, component.uuid(), hashFunction);
index 81cc9c9054718e527559396ce1d51f50d8e1a3dc..d94c6175671feaddb6823afcf258c38f87726af5 100644 (file)
@@ -21,9 +21,6 @@
 package org.sonar.server.source.ws;
 
 import com.google.common.io.Resources;
-import java.io.IOException;
-import java.util.List;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.server.ws.Response;
@@ -35,6 +32,10 @@ import org.sonar.server.db.DbClient;
 import org.sonar.server.source.SourceService;
 import org.sonar.server.user.UserSession;
 
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
 public class RawAction implements SourcesWsAction {
 
   private final DbClient dbClient;
@@ -48,7 +49,7 @@ public class RawAction implements SourcesWsAction {
   }
 
   @Override
-  public void  define(WebService.NewController controller) {
+  public void define(WebService.NewController controller) {
     WebService.NewAction action = controller.createAction("raw")
       .setDescription("Get source code as plain text. Require See Source Code permission on file")
       .setSince("5.0")
@@ -70,7 +71,7 @@ public class RawAction implements SourcesWsAction {
       ComponentDto componentDto = dbClient.componentDao().getByKey(session, fileKey);
       List<String> lines = sourceService.getLinesAsTxt(componentDto.uuid(), null, null);
       response.stream().setMediaType("text/plain");
-      IOUtils.writeLines(lines, "\n", response.stream().output(), Charsets.UTF_8);
+      IOUtils.writeLines(lines, "\n", response.stream().output(), StandardCharsets.UTF_8);
     } catch (IOException e) {
       throw new IllegalStateException("Fail to write raw source of file " + fileKey, e);
     }
index eb50d9a073212e858e979f9680307ac684848c16..163ad22b6d38a58fd71694f5bb8389564926f01a 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.startup;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.CharUtils;
@@ -34,6 +33,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 
 public final class GeneratePluginIndex implements ServerComponent {
 
@@ -51,7 +51,7 @@ public final class GeneratePluginIndex implements ServerComponent {
 
   void writeIndex(File indexFile) throws IOException {
     FileUtils.forceMkdir(indexFile.getParentFile());
-    Writer writer = new OutputStreamWriter(new FileOutputStream(indexFile), Charsets.UTF_8);
+    Writer writer = new OutputStreamWriter(new FileOutputStream(indexFile), StandardCharsets.UTF_8);
     try {
       for (PluginInfo pluginInfo : repository.getPluginInfos()) {
         writer.append(RemotePlugin.create(pluginInfo).marshal());
index 482b867635a1903fff3ecfc2e6da771945e6bdc4..d810a316b95131db08f5898706aa3db22b2ea17f 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.sonar.server.test.index;
 
-import org.apache.commons.io.Charsets;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.core.source.db.FileSourceDto;
@@ -34,6 +33,7 @@ import javax.annotation.Nullable;
 
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -91,7 +91,7 @@ public class TestResultSetIterator extends ResultSetIterator<Row> {
       ByteArrayOutputStream bytes = new ByteArrayOutputStream();
 
       // all the fields must be present, even if value is null
-      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, Charsets.UTF_8)).setSerializeNulls(true);
+      JsonWriter writer = JsonWriter.of(new OutputStreamWriter(bytes, StandardCharsets.UTF_8)).setSerializeNulls(true);
       writer.beginObject();
       writer.prop(FIELD_PROJECT_UUID, projectUuid);
       writer.prop(FIELD_FILE_UUID, fileUuid);
index 4d4fdef44d911a10f58c39a4394ec461789235ce..cc6c4737360754642562bee6c3f7c32f6065e673 100644 (file)
  */
 package org.sonar.server.ui.ws;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-import javax.annotation.Nullable;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.resources.Qualifiers;
 import org.sonar.api.resources.ResourceType;
@@ -53,6 +46,15 @@ import org.sonar.server.ui.ViewProxy;
 import org.sonar.server.ui.Views;
 import org.sonar.server.user.UserSession;
 
+import javax.annotation.Nullable;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
 public class ComponentNavigationAction implements NavigationWsAction {
 
   private static final String PARAM_COMPONENT_KEY = "componentKey";
@@ -163,7 +165,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
 
   private void writeExtensions(JsonWriter json, ComponentDto component, List<ViewProxy<Page>> pages, Locale locale) {
     json.name("extensions").beginArray();
-    for (ViewProxy<Page> page: pages) {
+    for (ViewProxy<Page> page : pages) {
       if (page.isUserAuthorized(component)) {
         writePage(json, getPageUrl(page, component), i18n.message(locale, page.getId() + ".page", page.getTitle()));
       }
@@ -185,7 +187,7 @@ public class ComponentNavigationAction implements NavigationWsAction {
   private static String encodeComponentKey(ComponentDto component) {
     String componentKey = component.getKey();
     try {
-      componentKey = URLEncoder.encode(componentKey, Charsets.UTF_8.name());
+      componentKey = URLEncoder.encode(componentKey, StandardCharsets.UTF_8.name());
     } catch (UnsupportedEncodingException unknownEncoding) {
       throw new IllegalStateException(unknownEncoding);
     }
index 98676d441faed846ae72e270cd1d917bed7cefeb..3fe0b5b96142c7819973d03925dad1747c9558c8 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.ws;
 
-import com.google.common.base.Charsets;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.api.utils.text.XmlWriter;
@@ -30,6 +29,7 @@ import javax.annotation.CheckForNull;
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 
 public class ServletResponse implements Response {
 
@@ -65,7 +65,7 @@ public class ServletResponse implements Response {
     }
 
     public String outputAsString() {
-      return new String(output.toByteArray(), Charsets.UTF_8);
+      return new String(output.toByteArray(), StandardCharsets.UTF_8);
     }
 
     public ServletStream reset() {
@@ -79,13 +79,13 @@ public class ServletResponse implements Response {
   @Override
   public JsonWriter newJsonWriter() {
     stream.setMediaType(MimeTypes.JSON);
-    return JsonWriter.of(new OutputStreamWriter(stream.output(), Charsets.UTF_8));
+    return JsonWriter.of(new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8));
   }
 
   @Override
   public XmlWriter newXmlWriter() {
     stream.setMediaType(MimeTypes.XML);
-    return XmlWriter.of(new OutputStreamWriter(stream.output(), Charsets.UTF_8));
+    return XmlWriter.of(new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8));
   }
 
   @Override
index 6df77bae14db855750c8cda8eac99f9bf3fe09f3..2b43b9c9f309ccf2039556e1f71c6ef863f259d7 100644 (file)
  */
 package org.sonar.server.ws;
 
-import com.google.common.base.Charsets;
-import java.io.OutputStreamWriter;
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
 import org.picocontainer.Startable;
 import org.sonar.api.ServerSide;
 import org.sonar.api.i18n.I18n;
@@ -38,6 +34,12 @@ import org.sonar.server.exceptions.ServerException;
 import org.sonar.server.plugins.MimeTypes;
 import org.sonar.server.user.UserSession;
 
+import javax.servlet.http.HttpServletResponse;
+
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+
 /**
  * @since 4.2
  */
@@ -120,7 +122,7 @@ public class WebServiceEngine implements Startable {
     stream.reset();
     stream.setStatus(status);
     stream.setMediaType(MimeTypes.JSON);
-    JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output(), Charsets.UTF_8));
+    JsonWriter json = JsonWriter.of(new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8));
 
     try {
       json.beginObject();
index d45cfc7a4ec045efa002a84b9b8e94e0736d82ed..33f94cf7010afebb0acad05605c7c7f6ab7b6756 100644 (file)
@@ -21,7 +21,6 @@
 package org.sonar.server.db.migrations.v50;
 
 import org.apache.commons.dbutils.DbUtils;
-import org.apache.commons.io.Charsets;
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -29,6 +28,7 @@ import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.core.persistence.DbTester;
 
+import java.nio.charset.StandardCharsets;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.util.List;
@@ -137,84 +137,84 @@ public class FeedFileSourcesTest {
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(1, 6, ?)");
-      revisionStmt.setBytes(1, "1=aef12a;2=abe465;3=afb789;4=afb789".getBytes(Charsets.UTF_8));
+      revisionStmt.setBytes(1, "1=aef12a;2=abe465;3=afb789;4=afb789".getBytes(StandardCharsets.UTF_8));
       revisionStmt.executeUpdate();
 
       PreparedStatement authorStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(2, 6, ?)");
-      authorStmt.setBytes(1, "1=alice;2=bob;3=carol;4=carol".getBytes(Charsets.UTF_8));
+      authorStmt.setBytes(1, "1=alice;2=bob;3=carol;4=carol".getBytes(StandardCharsets.UTF_8));
       authorStmt.executeUpdate();
 
       PreparedStatement dateStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(3, 6, ?)");
-      dateStmt.setBytes(1, "1=2014-04-25T12:34:56+0100;2=2014-07-25T12:34:56+0100;3=2014-03-23T12:34:56+0100;4=2014-03-23T12:34:56+0100".getBytes(Charsets.UTF_8));
+      dateStmt.setBytes(1, "1=2014-04-25T12:34:56+0100;2=2014-07-25T12:34:56+0100;3=2014-03-23T12:34:56+0100;4=2014-03-23T12:34:56+0100".getBytes(StandardCharsets.UTF_8));
       dateStmt.executeUpdate();
 
       PreparedStatement utHitsStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(4, 6, ?)");
-      utHitsStmt.setBytes(1, "1=1;3=0".getBytes(Charsets.UTF_8));
+      utHitsStmt.setBytes(1, "1=1;3=0".getBytes(StandardCharsets.UTF_8));
       utHitsStmt.executeUpdate();
 
       PreparedStatement utCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(5, 6, ?)");
-      utCondStmt.setBytes(1, "1=4".getBytes(Charsets.UTF_8));
+      utCondStmt.setBytes(1, "1=4".getBytes(StandardCharsets.UTF_8));
       utCondStmt.executeUpdate();
 
       PreparedStatement utCoveredCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(6, 6, ?)");
-      utCoveredCondStmt.setBytes(1, "1=2".getBytes(Charsets.UTF_8));
+      utCoveredCondStmt.setBytes(1, "1=2".getBytes(StandardCharsets.UTF_8));
       utCoveredCondStmt.executeUpdate();
 
       PreparedStatement itHitsStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(7, 6, ?)");
-      itHitsStmt.setBytes(1, "1=2;3=0".getBytes(Charsets.UTF_8));
+      itHitsStmt.setBytes(1, "1=2;3=0".getBytes(StandardCharsets.UTF_8));
       itHitsStmt.executeUpdate();
 
       PreparedStatement itCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(8, 6, ?)");
-      itCondStmt.setBytes(1, "1=5".getBytes(Charsets.UTF_8));
+      itCondStmt.setBytes(1, "1=5".getBytes(StandardCharsets.UTF_8));
       itCondStmt.executeUpdate();
 
       PreparedStatement itCoveredCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(9, 6, ?)");
-      itCoveredCondStmt.setBytes(1, "1=3".getBytes(Charsets.UTF_8));
+      itCoveredCondStmt.setBytes(1, "1=3".getBytes(StandardCharsets.UTF_8));
       itCoveredCondStmt.executeUpdate();
 
       PreparedStatement overallHitsStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(10, 6, ?)");
-      overallHitsStmt.setBytes(1, "1=3;3=0".getBytes(Charsets.UTF_8));
+      overallHitsStmt.setBytes(1, "1=3;3=0".getBytes(StandardCharsets.UTF_8));
       overallHitsStmt.executeUpdate();
 
       PreparedStatement overallCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(11, 6, ?)");
-      overallCondStmt.setBytes(1, "1=6".getBytes(Charsets.UTF_8));
+      overallCondStmt.setBytes(1, "1=6".getBytes(StandardCharsets.UTF_8));
       overallCondStmt.executeUpdate();
 
       PreparedStatement overallCoveredCondStmt = connection.prepareStatement("insert into project_measures " +
         "(metric_id, snapshot_id, " + columnName + ") " +
         "values " +
         "(12, 6, ?)");
-      overallCoveredCondStmt.setBytes(1, "1=4".getBytes(Charsets.UTF_8));
+      overallCoveredCondStmt.setBytes(1, "1=4".getBytes(StandardCharsets.UTF_8));
       overallCoveredCondStmt.executeUpdate();
 
       PreparedStatement duplicationDataStmt = connection.prepareStatement("insert into project_measures " +
@@ -225,7 +225,7 @@ public class FeedFileSourcesTest {
         .setBytes(
           1,
           "<duplications><g><b s=\"1\" l=\"1\" r=\"MyProject:src/main/xoo/prj/MyFile.xoo\"/><b s=\"2\" l=\"1\" r=\"MyProject:src/main/xoo/prj/MyFile.xoo\"/><b s=\"3\" l=\"1\" r=\"MyProject:src/main/xoo/prj/AnotherFile.xoo\"/></g></duplications>"
-            .getBytes(Charsets.UTF_8));
+            .getBytes(StandardCharsets.UTF_8));
       duplicationDataStmt.executeUpdate();
     } finally {
       DbUtils.commitAndCloseQuietly(connection);
@@ -283,7 +283,7 @@ public class FeedFileSourcesTest {
         .setBytes(
           1,
           "<duplications><g><b s=\"1\" l=\"1\" r=\"MyProject:src/main/xoo/prj/MyFile.xoo\"/><b s=\"2\" l=\"1\" r=\"MyProject:src/main/xoo/prj/MyFile.xoo\"/><b s=\"3\" l=\"1\" r=\"MyProject:src/main/xoo/prj/AnotherFile.xoo\"/"
-            .getBytes(Charsets.UTF_8));
+            .getBytes(StandardCharsets.UTF_8));
       duplicationDataStmt.executeUpdate();
     } finally {
       DbUtils.commitAndCloseQuietly(connection);
index 9d04d96d86cec823ff7713718c96bd039b2f8694..baf7ad8a5ea85d9477b8e64a20daa9bb0d9ee88c 100644 (file)
 
 package org.sonar.server.debt;
 
-import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import org.junit.Test;
 import org.sonar.api.server.debt.DebtCharacteristic;
 
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -108,7 +108,7 @@ public class DebtCharacteristicsXMLImporterTest {
   }
 
   private String getFileContent(String file) throws Exception {
-    return Resources.toString(Resources.getResource(getClass(), "DebtCharacteristicsXMLImporterTest/" + file), Charsets.UTF_8);
+    return Resources.toString(Resources.getResource(getClass(), "DebtCharacteristicsXMLImporterTest/" + file), StandardCharsets.UTF_8);
   }
 
 }
index 071a390ded6d117a1086408f148101de4de21456..f463fce9693e58e5d16a5c136219baff99125db3 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.debt;
 
-import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import org.apache.commons.lang.CharUtils;
 import org.apache.commons.lang.SystemUtils;
@@ -31,6 +30,7 @@ import org.sonar.api.rule.RuleKey;
 import org.sonar.api.server.debt.DebtRemediationFunction;
 import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Collections;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -65,7 +65,7 @@ public class DebtModelXMLExporterTest {
     List<RuleDebt> rules = newArrayList(
       new RuleDebt().setRuleKey(RuleKey.of("checkstyle", "Regexp"))
         .setSubCharacteristicKey("MEMORY_USE").setFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()).setCoefficient("3d").setOffset("15min")
-    );
+      );
 
     assertSimilarXml(getFileContent("export_xml.xml"), xmlExporter.export(debtModel, rules));
   }
@@ -109,7 +109,7 @@ public class DebtModelXMLExporterTest {
     List<RuleDebt> rules = newArrayList(
       new RuleDebt().setRuleKey(RuleKey.of("checkstyle", "Regexp"))
         .setSubCharacteristicKey("MEMORY_USE").setFunction(DebtRemediationFunction.Type.LINEAR.name()).setCoefficient("3d")
-    );
+      );
     assertThat(xmlExporter.export(debtModel, rules)).isEqualTo(
       "<sqale>" + SystemUtils.LINE_SEPARATOR +
         "  <chc>" + SystemUtils.LINE_SEPARATOR +
@@ -138,10 +138,10 @@ public class DebtModelXMLExporterTest {
         "    </chc>" + SystemUtils.LINE_SEPARATOR +
         "  </chc>" + SystemUtils.LINE_SEPARATOR +
         "</sqale>" + SystemUtils.LINE_SEPARATOR
-    );
+      );
   }
 
   private String getFileContent(String file) throws Exception {
-    return Resources.toString(Resources.getResource(getClass(), "DebtModelXMLExporterTest/" + file), Charsets.UTF_8);
+    return Resources.toString(Resources.getResource(getClass(), "DebtModelXMLExporterTest/" + file), StandardCharsets.UTF_8);
   }
 }
index 087e96116d914ae00541cde1e586fa1dbffc8ec7..233d486c2b0d1439a334ccc0fae5e59082e8b57b 100644 (file)
 
 package org.sonar.server.debt;
 
-import com.google.common.base.Charsets;
 import com.google.common.io.Resources;
 import org.junit.Test;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.server.debt.DebtRemediationFunction;
 import org.sonar.api.utils.ValidationMessages;
 
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -253,6 +253,6 @@ public class DebtRulesXMLImporterTest {
 
   private String getFileContent(String file) throws Exception {
     return Resources.toString(Resources.getResource(getClass(), "DebtRulesXMLImporterTest/" + file),
-      Charsets.UTF_8);
+      StandardCharsets.UTF_8);
   }
 }
index a4f439449291f34ab8984b163ac6fdc33a418d4c..0bbef9a73ddf22a107a25b317d3f7b160354e37e 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.sonar.server.duplication.ws;
 
-import com.google.common.base.Charsets;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Iterables;
 import com.google.common.io.Files;
@@ -39,6 +38,7 @@ import javax.annotation.Nullable;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -229,10 +229,10 @@ public class DuplicationsParserTest {
   }
 
   private String getData(String file) throws IOException {
-    return Files.toString(new File(Resources.getResource(this.getClass(), "DuplicationsParserTest/" + file).getFile()), Charsets.UTF_8);
+    return Files.toString(new File(Resources.getResource(this.getClass(), "DuplicationsParserTest/" + file).getFile()), StandardCharsets.UTF_8);
   }
 
-  private static DuplicationsParser.Duplication duplication(List<DuplicationsParser.Duplication> duplications, @Nullable final String componentKey){
+  private static DuplicationsParser.Duplication duplication(List<DuplicationsParser.Duplication> duplications, @Nullable final String componentKey) {
     return Iterables.find(duplications, new Predicate<DuplicationsParser.Duplication>() {
       @Override
       public boolean apply(@Nullable DuplicationsParser.Duplication input) {
index 3c82fb374dc1fd528e0ff49d5975780046368be4..0c0d3ede87fc2e3ef742cbaaeee389ae14a73b49 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.issue.notification;
 
 import com.google.common.io.Resources;
-import org.apache.commons.codec.Charsets;
 import org.apache.commons.lang.StringUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -34,6 +33,8 @@ import org.sonar.api.user.UserFinder;
 import org.sonar.core.component.ComponentDto;
 import org.sonar.plugins.emailnotifications.api.EmailMessage;
 
+import java.nio.charset.StandardCharsets;
+
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -73,7 +74,7 @@ public class IssueChangesEmailTemplateTest {
     String message = email.getMessage();
     String expected = Resources.toString(Resources.getResource(
       "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_assignee_change.txt"),
-      Charsets.UTF_8
+      StandardCharsets.UTF_8
       );
     expected = StringUtils.remove(expected, '\r');
     assertThat(message).isEqualTo(expected);
@@ -93,7 +94,7 @@ public class IssueChangesEmailTemplateTest {
     String message = email.getMessage();
     String expected = Resources.toString(Resources.getResource(
       "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_action_plan_change.txt"),
-      Charsets.UTF_8
+      StandardCharsets.UTF_8
       );
     expected = StringUtils.remove(expected, '\r');
     assertThat(message).isEqualTo(expected);
@@ -113,7 +114,7 @@ public class IssueChangesEmailTemplateTest {
     String message = email.getMessage();
     String expected = Resources.toString(Resources.getResource(
       "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_should_display_resolution_change.txt"),
-      Charsets.UTF_8
+      StandardCharsets.UTF_8
       );
     expected = StringUtils.remove(expected, '\r');
     assertThat(message).isEqualTo(expected);
@@ -132,7 +133,7 @@ public class IssueChangesEmailTemplateTest {
     String message = email.getMessage();
     String expected = Resources.toString(Resources.getResource(
       "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/display_component_key_if_no_component_name.txt"),
-      Charsets.UTF_8
+      StandardCharsets.UTF_8
       );
     expected = StringUtils.remove(expected, '\r');
     assertThat(message).isEqualTo(expected);
@@ -154,7 +155,7 @@ public class IssueChangesEmailTemplateTest {
 
     String message = email.getMessage();
     String expected = Resources.toString(Resources.getResource(
-      "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt"), Charsets.UTF_8);
+      "org/sonar/server/issue/notification/IssueChangesEmailTemplateTest/email_with_multiple_changes.txt"), StandardCharsets.UTF_8);
     expected = StringUtils.remove(expected, '\r');
     assertThat(message).isEqualTo(expected);
     assertThat(email.getFrom()).isNull();
index e30e67d1f3736751d5156fac4ae3b718d6e47c3d..750de90cdd0cff25fe364a5c6292db0dd2346bbf 100644 (file)
@@ -20,7 +20,6 @@
 
 package org.sonar.server.issue.notification;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,6 +32,7 @@ import org.sonar.plugins.emailnotifications.api.EmailMessage;
 import org.sonar.server.user.index.UserDoc;
 import org.sonar.server.user.index.UserIndex;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.Locale;
 
@@ -95,7 +95,7 @@ public class MyNewIssuesEmailTemplateTest {
     EmailMessage message = sut.format(notification);
 
     // TODO datetime to be completed when test is isolated from JVM timezone
-    String file = IOUtils.toString(getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_all_details.txt"), Charsets.UTF_8);
+    String file = IOUtils.toString(getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_all_details.txt"), StandardCharsets.UTF_8);
     assertThat(message.getMessage()).startsWith(file);
   }
 
@@ -124,7 +124,7 @@ public class MyNewIssuesEmailTemplateTest {
     EmailMessage message = sut.format(notification);
 
     // TODO datetime to be completed when test is isolated from JVM timezone
-    String file = IOUtils.toString(getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_no_assignee_tags_components.txt"), Charsets.UTF_8);
+    String file = IOUtils.toString(getClass().getResource("MyNewIssuesEmailTemplateTest/email_with_no_assignee_tags_components.txt"), StandardCharsets.UTF_8);
     assertThat(message.getMessage()).startsWith(file);
   }
 
index abd0556bc3c29b0f9eaaf269a142c72a4ed640cd..5e58492a861887469a3f942eaeb0456f1924b0af 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.issue.notification;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.junit.Before;
 import org.junit.Test;
@@ -32,13 +31,21 @@ import org.sonar.plugins.emailnotifications.api.EmailMessage;
 import org.sonar.server.user.index.UserDoc;
 import org.sonar.server.user.index.UserIndex;
 
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.*;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
-import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.*;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.ASSIGNEE;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.COMPONENT;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.DEBT;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.RULE;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.SEVERITY;
+import static org.sonar.server.issue.notification.NewIssuesStatistics.Metric.TAG;
 
 public class NewIssuesEmailTemplateTest {
 
@@ -104,7 +111,7 @@ public class NewIssuesEmailTemplateTest {
     EmailMessage message = template.format(notification);
 
     // TODO datetime to be completed when test is isolated from JVM timezone
-    String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_all_details.txt"), Charsets.UTF_8);
+    String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_all_details.txt"), StandardCharsets.UTF_8);
     assertThat(message.getMessage()).startsWith(expectedContent);
   }
 
@@ -115,7 +122,7 @@ public class NewIssuesEmailTemplateTest {
     EmailMessage message = template.format(notification);
 
     // TODO datetime to be completed when test is isolated from JVM timezone
-    String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_partial_details.txt"), Charsets.UTF_8);
+    String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_partial_details.txt"), StandardCharsets.UTF_8);
     assertThat(message.getMessage()).startsWith(expectedContent);
   }
 
index 9c9e5a5bf6a58b8ff8f6e365f23851f3c68ca1d3..9d6581bb5832a5300491ee8a89d4e6df755e91fa 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.plugins;
 
-import com.google.common.base.Charsets;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
@@ -30,6 +29,7 @@ import org.sonar.updatecenter.common.Version;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Matchers.any;
@@ -54,9 +54,9 @@ public class UpdateCenterClientTest {
 
   @Test
   public void downloadUpdateCenter() throws URISyntaxException {
-    when(reader.readString(new URI(BASE_URL), Charsets.UTF_8)).thenReturn("publicVersions=2.2,2.3");
+    when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("publicVersions=2.2,2.3");
     UpdateCenter plugins = client.getUpdateCenter();
-    verify(reader, times(1)).readString(new URI(BASE_URL), Charsets.UTF_8);
+    verify(reader, times(1)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
     assertThat(plugins.getSonar().getVersions()).containsOnly(Version.create("2.2"), Version.create("2.3"));
     assertThat(client.getLastRefreshDate()).isNotNull();
   }
@@ -68,27 +68,27 @@ public class UpdateCenterClientTest {
 
   @Test
   public void ignore_connection_errors() {
-    when(reader.readString(any(URI.class), eq(Charsets.UTF_8))).thenThrow(new SonarException());
+    when(reader.readString(any(URI.class), eq(StandardCharsets.UTF_8))).thenThrow(new SonarException());
     assertThat(client.getUpdateCenter()).isNull();
   }
 
   @Test
   public void cache_data() throws Exception {
-    when(reader.readString(new URI(BASE_URL), Charsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
+    when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
 
     client.getUpdateCenter();
     client.getUpdateCenter();
 
-    verify(reader, times(1)).readString(new URI(BASE_URL), Charsets.UTF_8);
+    verify(reader, times(1)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
   }
 
   @Test
   public void forceRefresh() throws Exception {
-    when(reader.readString(new URI(BASE_URL), Charsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
+    when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("sonar.versions=2.2,2.3");
 
     client.getUpdateCenter();
     client.getUpdateCenter(true);
 
-    verify(reader, times(2)).readString(new URI(BASE_URL), Charsets.UTF_8);
+    verify(reader, times(2)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
   }
 }
index 6417ff3686db3ccde419e0b4bdd5ec12597d933b..6c017b07ad776e0dc42edaab92ddcbc6fa6e0317 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.qualityprofile;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import com.google.common.io.Resources;
 import org.custommonkey.xmlunit.Diff;
@@ -39,13 +38,14 @@ import org.sonar.core.rule.RuleParamDto;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.rule.RuleTesting;
 import org.sonar.server.tester.ServerTester;
+import org.sonar.server.tester.UserSessionRule;
 
 import javax.xml.stream.XMLStreamException;
 
 import java.io.StringReader;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
-import org.sonar.server.tester.UserSessionRule;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -108,7 +108,7 @@ public class QProfileBackuperMediumTest {
     XMLUnit.setIgnoreWhitespace(true);
     XMLUnit.setIgnoreComments(true);
     Diff diff = XMLUnit.compareXML(output.toString(),
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/expected-backup.xml"), Charsets.UTF_8));
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/expected-backup.xml"), StandardCharsets.UTF_8));
 
     assertThat(diff.identical()).as(diff.toString()).isTrue();
   }
@@ -127,7 +127,7 @@ public class QProfileBackuperMediumTest {
   public void restore_and_create_profile() throws Exception {
     // Backup file declares profile P1 on xoo
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), Charsets.UTF_8)),
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), StandardCharsets.UTF_8)),
       null);
 
     QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage("P1", "xoo");
@@ -158,7 +158,7 @@ public class QProfileBackuperMediumTest {
     // restore backup, which activates only x1
     // -> update x1 and deactivate x2
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), Charsets.UTF_8)), null);
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), StandardCharsets.UTF_8)), null);
 
     List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY));
     assertThat(activeRules).hasSize(1);
@@ -185,7 +185,7 @@ public class QProfileBackuperMediumTest {
 
     // restore backup of child profile -> overrides x1
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore-child.xml"), Charsets.UTF_8)), null);
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore-child.xml"), StandardCharsets.UTF_8)), null);
 
     // parent profile is unchanged
     List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY));
@@ -220,7 +220,7 @@ public class QProfileBackuperMediumTest {
 
     // restore backup of parent profile -> update x1 and propagates to child
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore-parent.xml"), Charsets.UTF_8)), null);
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore-parent.xml"), StandardCharsets.UTF_8)), null);
 
     // parent profile is updated
     List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY));
@@ -255,7 +255,7 @@ public class QProfileBackuperMediumTest {
 
     // backup of child profile contains x2 but not x1
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/keep_other_inherited_rules.xml"), Charsets.UTF_8)), QProfileTesting.XOO_P2_NAME);
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/keep_other_inherited_rules.xml"), StandardCharsets.UTF_8)), QProfileTesting.XOO_P2_NAME);
 
     // x1 and x2
     List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P2_KEY));
@@ -266,7 +266,7 @@ public class QProfileBackuperMediumTest {
   public void fail_to_restore_if_not_xml_backup() throws Exception {
     try {
       tester.get(QProfileBackuper.class).restore(new StringReader(
-        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/not-xml-backup.txt"), Charsets.UTF_8)), null);
+        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/not-xml-backup.txt"), StandardCharsets.UTF_8)), null);
       fail();
     } catch (IllegalStateException e) {
       assertThat(e).hasMessage("Fail to restore Quality profile backup");
@@ -278,7 +278,7 @@ public class QProfileBackuperMediumTest {
   public void fail_to_restore_if_bad_xml_format() throws Exception {
     try {
       tester.get(QProfileBackuper.class).restore(new StringReader(
-        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/bad-xml-backup.xml"), Charsets.UTF_8)), null);
+        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/bad-xml-backup.xml"), StandardCharsets.UTF_8)), null);
       fail();
     } catch (IllegalArgumentException e) {
       assertThat(e).hasMessage("Backup XML is not valid. Root element must be <profile>.");
@@ -289,7 +289,7 @@ public class QProfileBackuperMediumTest {
   public void fail_to_restore_if_duplicate_rule() throws Exception {
     try {
       tester.get(QProfileBackuper.class).restore(new StringReader(
-        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/duplicates-xml-backup.xml"), Charsets.UTF_8)), null);
+        Resources.toString(getClass().getResource("QProfileBackuperMediumTest/duplicates-xml-backup.xml"), StandardCharsets.UTF_8)), null);
       fail();
     } catch (IllegalArgumentException e) {
       assertThat(e).hasMessage("The quality profile cannot be restored as it contains duplicates for the following rules: xoo:x1, xoo:x2");
@@ -299,7 +299,7 @@ public class QProfileBackuperMediumTest {
   @Test
   public void restore_and_override_profile_name() throws Exception {
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), Charsets.UTF_8)),
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), StandardCharsets.UTF_8)),
       QProfileTesting.XOO_P3_NAME);
 
     List<ActiveRule> activeRules = Lists.newArrayList(tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY));
@@ -314,7 +314,7 @@ public class QProfileBackuperMediumTest {
   @Test
   public void restore_profile_with_zero_rules() throws Exception {
     tester.get(QProfileBackuper.class).restore(new StringReader(
-      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/empty.xml"), Charsets.UTF_8)),
+      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/empty.xml"), StandardCharsets.UTF_8)),
       null);
 
     dbSession.clearCache();
index 56d686142a503e1d1d3a767866095c1d3024e600..cd6e4e121eff8e7113df10e34259e5dabb1ca3d2 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.startup;
 
-import com.google.common.base.Charsets;
 import com.google.common.io.Files;
 import com.google.common.io.Resources;
 import org.junit.Rule;
@@ -29,6 +28,7 @@ import org.sonar.api.config.Settings;
 import org.sonar.server.platform.DefaultServerFileSystem;
 
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
@@ -60,7 +60,7 @@ public class JdbcDriverDeployerTest {
     assertThat(deployedFile).exists();
     assertThat(deployedFile).hasContentEqualTo(driver);
 
-    assertThat(Files.toString(deployedIndex, Charsets.UTF_8)).isEqualTo("my-driver.jar|02b97f7bc37b2b68fc847fcc3fc1c156");
+    assertThat(Files.toString(deployedIndex, StandardCharsets.UTF_8)).isEqualTo("my-driver.jar|02b97f7bc37b2b68fc847fcc3fc1c156");
   }
 
   @Test
index 1be9064a18890b2c5639cb253e74bfb2c13c8fe3..6608f18be0f81f0a0dd73ec2e4835ccfeac0606c 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.server.ws;
 
 import com.google.common.collect.Maps;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
@@ -39,6 +38,7 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -137,12 +137,12 @@ public class WsTester {
 
     @Override
     public JsonWriter newJsonWriter() {
-      return JsonWriter.of(new OutputStreamWriter(output, Charsets.UTF_8));
+      return JsonWriter.of(new OutputStreamWriter(output, StandardCharsets.UTF_8));
     }
 
     @Override
     public XmlWriter newXmlWriter() {
-      return XmlWriter.of(new OutputStreamWriter(output, Charsets.UTF_8));
+      return XmlWriter.of(new OutputStreamWriter(output, StandardCharsets.UTF_8));
     }
 
     @Override
@@ -161,7 +161,7 @@ public class WsTester {
     }
 
     public String outputAsString() {
-      return new String(output.toByteArray(), Charsets.UTF_8);
+      return new String(output.toByteArray(), StandardCharsets.UTF_8);
     }
   }
 
@@ -177,7 +177,7 @@ public class WsTester {
     }
 
     public String outputAsString() {
-      return new String(response.output.toByteArray(), Charsets.UTF_8);
+      return new String(response.output.toByteArray(), StandardCharsets.UTF_8);
     }
 
     public byte[] output() {
index 167b8a3e0c735fb77e4c8bb28ea8abcdce6090a0..c6c3404d0b383bf8d7c6ec9db75150af584b5093 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.application;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.sonar.process.ConfigurationUtils;
@@ -32,6 +31,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.Properties;
 
 class PropsBuilder {
@@ -87,7 +87,7 @@ class PropsBuilder {
     Properties p = new Properties();
     File propsFile = new File(homeDir, "conf/sonar.properties");
     if (propsFile.exists()) {
-      Reader reader = new InputStreamReader(new FileInputStream(propsFile), Charsets.UTF_8);
+      Reader reader = new InputStreamReader(new FileInputStream(propsFile), StandardCharsets.UTF_8);
       try {
         p.load(reader);
       } finally {
index 9dd5c240dabca90dfc59485ea5dba0a3c5842629..429a776ba3e98d94d885dc148abac258c281ad1b 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.application;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
 import org.junit.Rule;
@@ -29,6 +28,7 @@ import org.sonar.process.Props;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Properties;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -122,7 +122,7 @@ public class PropsBuilderTest {
 
   @Test
   public void utf8_file_encoding() throws Exception {
-    FileUtils.write(new File(homeDir, "conf/sonar.properties"), "utf8prop=Thônes", Charsets.UTF_8);
+    FileUtils.write(new File(homeDir, "conf/sonar.properties"), "utf8prop=Thônes", StandardCharsets.UTF_8);
     Props props = new PropsBuilder(new Properties(), jdbcSettings, homeDir).build();
     assertThat(props.value("utf8prop")).isEqualTo("Thônes");
   }
index 35f1d896d34b1392a53e0f554f06bb034d16229d..48b65acaaf9ee43fca6d3ddd856bcc253f4e4af2 100644 (file)
@@ -21,11 +21,11 @@ package org.sonar.colorizer;
 
 import com.google.common.io.ByteStreams;
 import com.google.common.io.Closeables;
-import org.apache.commons.io.Charsets;
 import org.sonar.channel.CodeReader;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 
 /**
  * @deprecated since 4.5.2 replace by highlighting mechanism
@@ -99,7 +99,7 @@ public class HtmlDecorator extends Tokenizer {
     InputStream input = null;
     try {
       input = HtmlRenderer.class.getResourceAsStream(CSS_PATH);
-      return new String(ByteStreams.toByteArray(input), Charsets.UTF_8);
+      return new String(ByteStreams.toByteArray(input), StandardCharsets.UTF_8);
 
     } catch (IOException e) {
       throw new SynhtaxHighlightingException("SonarQube Colorizer CSS file not found: " + CSS_PATH, e);
index 241d26451408947e89bbda053548f8c3f194020f..a837bbf9ac09bd82e6501fd0feccf61ba6b23555 100644 (file)
@@ -23,7 +23,6 @@ import com.tinkerpop.blueprints.Direction;
 import com.tinkerpop.blueprints.Edge;
 import com.tinkerpop.blueprints.Element;
 import com.tinkerpop.blueprints.Vertex;
-import org.apache.commons.io.Charsets;
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
@@ -34,7 +33,14 @@ import javax.annotation.Nullable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.util.*;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import static org.sonar.core.graph.graphson.ElementPropertyConfig.ElementPropertiesRule;
 
@@ -549,7 +555,7 @@ class GraphsonUtil {
    * Creates a vertex from GraphSON using settings supplied in the constructor.
    */
   Vertex vertexFromJson(InputStream json) throws ParseException, IOException {
-    return this.vertexFromJson((JSONObject) parser.parse(new InputStreamReader(json, Charsets.UTF_8)));
+    return this.vertexFromJson((JSONObject) parser.parse(new InputStreamReader(json, StandardCharsets.UTF_8)));
   }
 
   /**
@@ -563,7 +569,7 @@ class GraphsonUtil {
    * Creates an edge from GraphSON using settings supplied in the constructor.
    */
   Edge edgeFromJson(InputStream json, Vertex out, Vertex in) throws IOException, ParseException {
-    return this.edgeFromJson((JSONObject) parser.parse(new InputStreamReader(json, Charsets.UTF_8)), out, in);
+    return this.edgeFromJson((JSONObject) parser.parse(new InputStreamReader(json, StandardCharsets.UTF_8)), out, in);
   }
 
   /**
index 990e8dfd512a51d6f59d069cc2af039a29bea6de..7b4e45e2cdcbcb5575ccc30fef8c9503572dc69f 100644 (file)
 
 package org.sonar.core.measure.db;
 
-import com.google.common.base.Charsets;
 import org.sonar.api.rule.Severity;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 
+import java.nio.charset.StandardCharsets;
+
 import static com.google.common.base.Preconditions.checkArgument;
 
 public class MeasureDto {
@@ -75,7 +76,7 @@ public class MeasureDto {
   @CheckForNull
   public String getData() {
     if (dataValue != null) {
-      return new String(dataValue, Charsets.UTF_8);
+      return new String(dataValue, StandardCharsets.UTF_8);
     }
     return textValue;
   }
@@ -86,7 +87,7 @@ public class MeasureDto {
       this.dataValue = null;
     } else if (data.length() > MAX_TEXT_VALUE_LENGTH) {
       this.textValue = null;
-      this.dataValue = data.getBytes(Charsets.UTF_8);
+      this.dataValue = data.getBytes(StandardCharsets.UTF_8);
     } else {
       this.textValue = data;
       this.dataValue = null;
index 64a4a43942e1fdbadd15e862bb2faa83d437b3eb..ad63f77f220dc8e293894c830877af929ff9eb23 100644 (file)
@@ -29,7 +29,6 @@ import com.google.common.io.CharStreams;
 import com.google.common.io.Files;
 import com.google.common.io.InputSupplier;
 import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.sonar.api.config.Settings;
@@ -50,6 +49,7 @@ import java.net.Proxy;
 import java.net.ProxySelector;
 import java.net.URI;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 import java.util.Map;
 import java.util.zip.GZIPInputStream;
@@ -282,7 +282,7 @@ public class DefaultHttpDownloader extends HttpDownloader {
         // allow both GZip and Deflate (ZLib) encodings
         connection.setRequestProperty("Accept-Encoding", "gzip");
         if (!Strings.isNullOrEmpty(login)) {
-          String encoded = Base64.encodeBase64String((login + ":" + password).getBytes(Charsets.UTF_8));
+          String encoded = Base64.encodeBase64String((login + ":" + password).getBytes(StandardCharsets.UTF_8));
           connection.setRequestProperty("Authorization", "Basic " + encoded);
         }
         connection.setConnectTimeout(TIMEOUT_MILLISECONDS);
index 06dcdedf7c18bc390d3667841a1a5dddd4bbd2b0..75dc1732b0a4cb87ec189801ff7ec72b404f0239 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.core.util;
 
-import com.google.common.base.Charsets;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.junit.AfterClass;
@@ -49,6 +48,7 @@ import java.net.SocketAddress;
 import java.net.SocketTimeoutException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Properties;
 import java.util.zip.GZIPOutputStream;
@@ -132,19 +132,19 @@ public class DefaultHttpDownloaderTest {
 
   @Test
   public void readString() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl), Charsets.UTF_8);
+    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl), StandardCharsets.UTF_8);
     assertThat(text.length()).isGreaterThan(10);
   }
 
   @Test
   public void readGzipString() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/gzip/"), Charsets.UTF_8);
+    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/gzip/"), StandardCharsets.UTF_8);
     assertThat(text).isEqualTo("GZIP response");
   }
 
   @Test
   public void readStringWithDefaultTimeout() throws URISyntaxException {
-    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/timeout/"), Charsets.UTF_8);
+    String text = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
     assertThat(text.length()).isGreaterThan(10);
   }
 
@@ -160,7 +160,7 @@ public class DefaultHttpDownloaderTest {
       public void describeTo(Description arg0) {
       }
     });
-    new DefaultHttpDownloader(new Settings(), 50).readString(new URI(baseUrl + "/timeout/"), Charsets.UTF_8);
+    new DefaultHttpDownloader(new Settings(), 50).readString(new URI(baseUrl + "/timeout/"), StandardCharsets.UTF_8);
   }
 
   @Test
@@ -201,7 +201,7 @@ public class DefaultHttpDownloaderTest {
 
   @Test
   public void followRedirect() throws URISyntaxException {
-    String content = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/redirect/"), Charsets.UTF_8);
+    String content = new DefaultHttpDownloader(new Settings()).readString(new URI(baseUrl + "/redirect/"), StandardCharsets.UTF_8);
     assertThat(content).contains("agent");
   }
 
index a60c04e86d3c5523e78907d7c041e6f44c116897..904820856d85751e226ab3f328fd17070a11e0c5 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.duplications.java;
 
-import com.google.common.base.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 import org.sonar.duplications.DuplicationsTestUtil;
@@ -32,6 +31,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -327,7 +327,7 @@ public class JavaStatementBuilderTest {
   private List<Statement> chunk(File file) {
     Reader reader = null;
     try {
-      reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
+      reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
       return statementChunker.chunk(tokenChunker.chunk(reader));
     } catch (FileNotFoundException e) {
       throw new RuntimeException(e);
index 3a190a5e3be20ea41aa75d2f6a3c2e1f97be1c01..1afeb632b9ca9be2cb933e9984cdce1a2c8546fb 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.duplications.java;
 
-import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import org.apache.commons.io.IOUtils;
 import org.hamcrest.Matcher;
@@ -35,6 +34,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.List;
 
@@ -284,11 +284,11 @@ public class JavaTokenProducerTest {
   @Test
   public void shouldPreserveSeparators() {
     assertThat(chunk("(){}[];,."), isTokens(
-        new Token("(", 1, 0), new Token(")", 1, 1),
-        new Token("{", 1, 2), new Token("}", 1, 3),
-        new Token("[", 1, 4), new Token("]", 1, 5),
-        new Token(";", 1, 6), new Token(",", 1, 7),
-        new Token(".", 1, 8)));
+      new Token("(", 1, 0), new Token(")", 1, 1),
+      new Token("{", 1, 2), new Token("}", 1, 3),
+      new Token("[", 1, 4), new Token("]", 1, 5),
+      new Token(";", 1, 6), new Token(",", 1, 7),
+      new Token(".", 1, 8)));
   }
 
   /**
@@ -312,7 +312,7 @@ public class JavaTokenProducerTest {
   private TokenQueue chunk(File file) {
     Reader reader = null;
     try {
-      reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
+      reader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);
       return chunker.chunk(reader);
     } catch (FileNotFoundException e) {
       throw new RuntimeException(e);
index 2632d9e250421b2c1b33f852f5ee50351064d470..9e6cc013149dabf22642f98370f46f9c6201ef9d 100644 (file)
@@ -22,12 +22,12 @@ package org.sonar.test;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonParser;
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.junit.ComparisonFailure;
 
 import java.io.IOException;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 
 /**
  * Assertion to compare JSON documents. Comparison is not strict:
@@ -100,7 +100,7 @@ public class JsonAssert {
 
   private static String urlToString(URL url) {
     try {
-      return IOUtils.toString(url, Charsets.UTF_8);
+      return IOUtils.toString(url, StandardCharsets.UTF_8);
     } catch (IOException e) {
       throw new IllegalStateException("Fail to load JSON from " + url, e);
     }
index 00b333144ad21e33a2040bf8f47d4d7eb7a662d5..2eb2430efcda8cb4b1f8378f3c5f08c3c14b81fa 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.test.i18n;
 
-import org.apache.commons.io.Charsets;
 import org.apache.commons.io.IOUtils;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
@@ -30,6 +29,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
 import java.util.Map;
 import java.util.Properties;
 import java.util.SortedMap;
@@ -121,7 +121,7 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
       dumpFile.delete();
     }
     dumpFile.getParentFile().mkdirs();
-    try (Writer writer = new OutputStreamWriter(new FileOutputStream(dumpFile), Charsets.UTF_8)) {
+    try (Writer writer = new OutputStreamWriter(new FileOutputStream(dumpFile), StandardCharsets.UTF_8)) {
       writer.write(details);
     } catch (IOException e) {
       throw new IllegalStateException("Unable to write the report to 'target/l10n/" + bundleName + ".report.txt'", e);