diff --git a/api/src/main/java/io/druid/data/input/impl/StringInputRowParser.java b/api/src/main/java/io/druid/data/input/impl/StringInputRowParser.java index cefe4706e2f..2a7fcdca80a 100644 --- a/api/src/main/java/io/druid/data/input/impl/StringInputRowParser.java +++ b/api/src/main/java/io/druid/data/input/impl/StringInputRowParser.java @@ -21,7 +21,6 @@ package io.druid.data.input.impl; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.collect.Iterators; import io.druid.data.input.ByteBufferInputRowParser; @@ -36,6 +35,7 @@ import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.CoderResult; import java.nio.charset.CodingErrorAction; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; @@ -43,7 +43,7 @@ import java.util.Map; */ public class StringInputRowParser implements ByteBufferInputRowParser { - private static final Charset DEFAULT_CHARSET = Charsets.UTF_8; + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; private final ParseSpec parseSpec; private final MapInputRowParser mapParser; diff --git a/api/src/test/java/io/druid/data/input/impl/InputRowParserSerdeTest.java b/api/src/test/java/io/druid/data/input/impl/InputRowParserSerdeTest.java index c7cb2df6340..d9da1907a0e 100644 --- a/api/src/test/java/io/druid/data/input/impl/InputRowParserSerdeTest.java +++ b/api/src/test/java/io/druid/data/input/impl/InputRowParserSerdeTest.java @@ -20,7 +20,6 @@ package io.druid.data.input.impl; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; @@ -37,6 +36,7 @@ import org.junit.Test; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -73,8 +73,8 @@ public class InputRowParserSerdeTest public void testStringInputRowParserSerdeMultiCharset() throws Exception { Charset[] testCharsets = { - Charsets.US_ASCII, Charsets.ISO_8859_1, Charsets.UTF_8, - Charsets.UTF_16BE, Charsets.UTF_16LE, Charsets.UTF_16 + StandardCharsets.US_ASCII, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8, + StandardCharsets.UTF_16BE, StandardCharsets.UTF_16LE, StandardCharsets.UTF_16 }; for (Charset testCharset : testCharsets) { diff --git a/api/src/test/java/io/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java b/api/src/test/java/io/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java index 340da4d4934..2d43fc3179a 100644 --- a/api/src/test/java/io/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java +++ b/api/src/test/java/io/druid/data/input/impl/prefetch/PrefetchableTextFilesFirehoseFactoryTest.java @@ -19,7 +19,6 @@ package io.druid.data.input.impl.prefetch; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.Lists; @@ -82,7 +81,7 @@ public class PrefetchableTextFilesFirehoseFactoryTest false, 0 ), - Charsets.UTF_8.name() + StandardCharsets.UTF_8.name() ); @Rule diff --git a/codestyle/druid-forbidden-apis.txt b/codestyle/druid-forbidden-apis.txt index 96db0882600..c50619d0cf4 100644 --- a/codestyle/druid-forbidden-apis.txt +++ b/codestyle/druid-forbidden-apis.txt @@ -1,4 +1,5 @@ com.google.common.collect.MapMaker @ Create java.util.concurrent.ConcurrentHashMap directly com.google.common.collect.Maps#newConcurrentMap() @ Create java.util.concurrent.ConcurrentHashMap directly com.google.common.util.concurrent.Futures#transform(com.google.common.util.concurrent.ListenableFuture, com.google.common.util.concurrent.AsyncFunction) @ Use io.druid.java.util.common.concurrent.ListenableFutures#transformAsync -com.google.common.collect.Iterators#emptyIterator() @ Use java.util.Collections#emptyIterator() \ No newline at end of file +com.google.common.collect.Iterators#emptyIterator() @ Use java.util.Collections#emptyIterator() +com.google.common.base.Charsets @ Use java.nio.charset.StandardCharsets instead \ No newline at end of file diff --git a/extensions-contrib/azure-extensions/src/test/java/io/druid/storage/azure/AzureTaskLogsTest.java b/extensions-contrib/azure-extensions/src/test/java/io/druid/storage/azure/AzureTaskLogsTest.java index 5f8394a735a..456d80b530e 100644 --- a/extensions-contrib/azure-extensions/src/test/java/io/druid/storage/azure/AzureTaskLogsTest.java +++ b/extensions-contrib/azure-extensions/src/test/java/io/druid/storage/azure/AzureTaskLogsTest.java @@ -19,7 +19,6 @@ package io.druid.storage.azure; -import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.io.ByteSource; import com.google.common.io.Files; @@ -34,6 +33,7 @@ import org.junit.Test; import java.io.ByteArrayInputStream; import java.io.File; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expectLastCall; @@ -88,7 +88,7 @@ public class AzureTaskLogsTest extends EasyMockSupport expect(azureStorage.getBlobExists(container, blobPath)).andReturn(true); expect(azureStorage.getBlobLength(container, blobPath)).andReturn((long) testLog.length()); expect(azureStorage.getBlobInputStream(container, blobPath)).andReturn( - new ByteArrayInputStream(testLog.getBytes(Charsets.UTF_8))); + new ByteArrayInputStream(testLog.getBytes(StandardCharsets.UTF_8))); replayAll(); @@ -111,7 +111,7 @@ public class AzureTaskLogsTest extends EasyMockSupport expect(azureStorage.getBlobExists(container, blobPath)).andReturn(true); expect(azureStorage.getBlobLength(container, blobPath)).andReturn((long) testLog.length()); expect(azureStorage.getBlobInputStream(container, blobPath)).andReturn( - new ByteArrayInputStream(testLog.getBytes(Charsets.UTF_8))); + new ByteArrayInputStream(testLog.getBytes(StandardCharsets.UTF_8))); replayAll(); diff --git a/extensions-contrib/time-min-max/src/test/java/io/druid/query/aggregation/TimestampAggregationSelectTest.java b/extensions-contrib/time-min-max/src/test/java/io/druid/query/aggregation/TimestampAggregationSelectTest.java index 58fbdc70062..e862d3fcec0 100644 --- a/extensions-contrib/time-min-max/src/test/java/io/druid/query/aggregation/TimestampAggregationSelectTest.java +++ b/extensions-contrib/time-min-max/src/test/java/io/druid/query/aggregation/TimestampAggregationSelectTest.java @@ -19,7 +19,6 @@ package io.druid.query.aggregation; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; @@ -41,6 +40,7 @@ import org.junit.runners.Parameterized; import javax.annotation.Nullable; import java.io.File; +import java.nio.charset.StandardCharsets; import java.sql.Timestamp; import java.util.List; import java.util.zip.ZipFile; @@ -147,7 +147,7 @@ public class TimestampAggregationSelectTest 0, Granularities.MONTH, 100, - Resources.toString(Resources.getResource("select.json"), Charsets.UTF_8) + Resources.toString(Resources.getResource("select.json"), StandardCharsets.UTF_8) ); Result result = (Result) Iterables.getOnlyElement(seq.toList()); diff --git a/extensions-core/datasketches/src/main/java/io/druid/query/aggregation/datasketches/quantiles/DoublesSketchOperations.java b/extensions-core/datasketches/src/main/java/io/druid/query/aggregation/datasketches/quantiles/DoublesSketchOperations.java index 5a0f70e6b76..48e3f3c1187 100644 --- a/extensions-core/datasketches/src/main/java/io/druid/query/aggregation/datasketches/quantiles/DoublesSketchOperations.java +++ b/extensions-core/datasketches/src/main/java/io/druid/query/aggregation/datasketches/quantiles/DoublesSketchOperations.java @@ -19,13 +19,12 @@ package io.druid.query.aggregation.datasketches.quantiles; -import org.apache.commons.codec.binary.Base64; - -import com.google.common.base.Charsets; import com.yahoo.memory.Memory; import com.yahoo.sketches.quantiles.DoublesSketch; - import io.druid.java.util.common.ISE; +import org.apache.commons.codec.binary.Base64; + +import java.nio.charset.StandardCharsets; public class DoublesSketchOperations { @@ -48,7 +47,7 @@ public class DoublesSketchOperations public static DoublesSketch deserializeFromBase64EncodedString(final String str) { - return deserializeFromByteArray(Base64.decodeBase64(str.getBytes(Charsets.UTF_8))); + return deserializeFromByteArray(Base64.decodeBase64(str.getBytes(StandardCharsets.UTF_8))); } public static DoublesSketch deserializeFromByteArray(final byte[] data) diff --git a/extensions-core/hdfs-storage/src/test/java/io/druid/indexing/common/tasklogs/HdfsTaskLogsTest.java b/extensions-core/hdfs-storage/src/test/java/io/druid/indexing/common/tasklogs/HdfsTaskLogsTest.java index 981fb51bf25..9e4843417a5 100644 --- a/extensions-core/hdfs-storage/src/test/java/io/druid/indexing/common/tasklogs/HdfsTaskLogsTest.java +++ b/extensions-core/hdfs-storage/src/test/java/io/druid/indexing/common/tasklogs/HdfsTaskLogsTest.java @@ -19,7 +19,6 @@ package io.druid.indexing.common.tasklogs; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteStreams; import com.google.common.io.Files; @@ -37,6 +36,7 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; public class HdfsTaskLogsTest @@ -50,7 +50,7 @@ public class HdfsTaskLogsTest final File tmpDir = tempFolder.newFolder(); final File logDir = new File(tmpDir, "logs"); final File logFile = new File(tmpDir, "log"); - Files.write("blah", logFile, Charsets.UTF_8); + Files.write("blah", logFile, StandardCharsets.UTF_8); final TaskLogs taskLogs = new HdfsTaskLogs(new HdfsTaskLogsConfig(logDir.toString()), new Configuration()); taskLogs.pushTaskLog("foo", logFile); @@ -69,11 +69,11 @@ public class HdfsTaskLogsTest final File logFile = new File(tmpDir, "log"); final TaskLogs taskLogs = new HdfsTaskLogs(new HdfsTaskLogsConfig(logDir.toString()), new Configuration()); - Files.write("blah", logFile, Charsets.UTF_8); + Files.write("blah", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("foo", logFile); Assert.assertEquals("blah", readLog(taskLogs, "foo", 0)); - Files.write("blah blah", logFile, Charsets.UTF_8); + Files.write("blah blah", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("foo", logFile); Assert.assertEquals("blah blah", readLog(taskLogs, "foo", 0)); } @@ -90,7 +90,7 @@ public class HdfsTaskLogsTest final TaskLogs taskLogs = new HdfsTaskLogs(new HdfsTaskLogsConfig(logDir.toString()), new Configuration()); - Files.write("log1content", logFile, Charsets.UTF_8); + Files.write("log1content", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("log1", logFile); Assert.assertEquals("log1content", readLog(taskLogs, "log1", 0)); @@ -101,7 +101,7 @@ public class HdfsTaskLogsTest long time = (System.currentTimeMillis() / 1000) * 1000; Assert.assertTrue(fs.getFileStatus(new Path(logDirPath, "log1")).getModificationTime() < time); - Files.write("log2content", logFile, Charsets.UTF_8); + Files.write("log2content", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("log2", logFile); Assert.assertEquals("log2content", readLog(taskLogs, "log2", 0)); Assert.assertTrue(fs.getFileStatus(new Path(logDirPath, "log2")).getModificationTime() >= time); diff --git a/extensions-core/kafka-indexing-service/src/main/java/io/druid/indexing/kafka/KafkaIndexTaskClient.java b/extensions-core/kafka-indexing-service/src/main/java/io/druid/indexing/kafka/KafkaIndexTaskClient.java index c869ed4665b..315cc0fda93 100644 --- a/extensions-core/kafka-indexing-service/src/main/java/io/druid/indexing/kafka/KafkaIndexTaskClient.java +++ b/extensions-core/kafka-indexing-service/src/main/java/io/druid/indexing/kafka/KafkaIndexTaskClient.java @@ -22,7 +22,6 @@ package io.druid.indexing.kafka; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; @@ -57,6 +56,7 @@ import javax.ws.rs.core.MediaType; import java.io.IOException; import java.net.Socket; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.Callable; @@ -551,7 +551,7 @@ public class KafkaIndexTaskClient } log.debug("HTTP %s: %s", method.getName(), serviceUri.toString()); - response = httpClient.go(request, new FullResponseHandler(Charsets.UTF_8), httpTimeout).get(); + response = httpClient.go(request, new FullResponseHandler(StandardCharsets.UTF_8), httpTimeout).get(); } catch (Exception e) { Throwables.propagateIfInstanceOf(e.getCause(), IOException.class); diff --git a/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/KafkaIndexTaskTest.java b/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/KafkaIndexTaskTest.java index 13452ce4227..8bdd3c7f087 100644 --- a/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/KafkaIndexTaskTest.java +++ b/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/KafkaIndexTaskTest.java @@ -22,7 +22,6 @@ package io.druid.indexing.kafka; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.base.Throwables; @@ -151,6 +150,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -224,7 +224,7 @@ public class KafkaIndexTaskTest new JSONPathSpec(true, ImmutableList.of()), ImmutableMap.of() ), - Charsets.UTF_8.name() + StandardCharsets.UTF_8.name() ), Map.class ), diff --git a/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java b/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java index a152fff6c68..f1c8ce97c9f 100644 --- a/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java +++ b/extensions-core/kafka-indexing-service/src/test/java/io/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java @@ -20,7 +20,6 @@ package io.druid.indexing.kafka.supervisor; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -91,6 +90,7 @@ import org.junit.runners.Parameterized; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -2003,7 +2003,7 @@ public class KafkaSupervisorTest extends EasyMockSupport new JSONPathSpec(true, ImmutableList.of()), ImmutableMap.of() ), - Charsets.UTF_8.name() + StandardCharsets.UTF_8.name() ), Map.class ), diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/data/input/MapPopulator.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/data/input/MapPopulator.java index c0b768d3cb7..fd6f122ad0d 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/data/input/MapPopulator.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/data/input/MapPopulator.java @@ -19,13 +19,13 @@ package io.druid.data.input; -import com.google.common.base.Charsets; import com.google.common.io.ByteSource; import com.google.common.io.LineProcessor; import io.druid.java.util.common.ISE; import io.druid.java.util.common.parsers.Parser; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -79,7 +79,7 @@ public class MapPopulator */ public PopulateResult populate(final ByteSource source, final Map map) throws IOException { - return source.asCharSource(Charsets.UTF_8).readLines( + return source.asCharSource(StandardCharsets.UTF_8).readLines( new LineProcessor() { private int lines = 0; diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java index e636d66bdc5..c07c1ea43d9 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java @@ -19,9 +19,7 @@ package io.druid.query.lookup.namespace; - import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; @@ -39,6 +37,7 @@ import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -68,7 +67,7 @@ public class JSONFlatDataParserTest public void setUp() throws Exception { tmpFile = temporaryFolder.newFile("lookup.json"); - final CharSink sink = Files.asByteSink(tmpFile).asCharSink(Charsets.UTF_8); + final CharSink sink = Files.asByteSink(tmpFile).asCharSink(StandardCharsets.UTF_8); sink.writeLines( Iterables.transform( MAPPINGS, diff --git a/indexing-hadoop/src/test/java/io/druid/indexer/hadoop/DatasourceInputFormatTest.java b/indexing-hadoop/src/test/java/io/druid/indexer/hadoop/DatasourceInputFormatTest.java index 0617b8ca55d..1b4af099662 100644 --- a/indexing-hadoop/src/test/java/io/druid/indexer/hadoop/DatasourceInputFormatTest.java +++ b/indexing-hadoop/src/test/java/io/druid/indexer/hadoop/DatasourceInputFormatTest.java @@ -19,7 +19,6 @@ package io.druid.indexer.hadoop; -import com.google.common.base.Charsets; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -51,6 +50,7 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.stream.Stream; @@ -281,7 +281,7 @@ public class DatasourceInputFormatTest { // Use the builtin supplier, reading from the local filesystem, rather than testFormatter. final File tmpFile = temporaryFolder.newFile("something:with:colons"); - Files.write("dummy", tmpFile, Charsets.UTF_8); + Files.write("dummy", tmpFile, StandardCharsets.UTF_8); final ImmutableList mySegments = ImmutableList.of( WindowedDataSegment.of( diff --git a/indexing-service/src/main/java/io/druid/indexing/common/task/MergeTaskBase.java b/indexing-service/src/main/java/io/druid/indexing/common/task/MergeTaskBase.java index 747cf58d416..7f2cae1a08e 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/task/MergeTaskBase.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/task/MergeTaskBase.java @@ -21,7 +21,6 @@ package io.druid.indexing.common.task; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Objects; @@ -34,9 +33,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import com.google.common.collect.Sets; import com.google.common.hash.Hashing; -import io.druid.java.util.emitter.EmittingLogger; -import io.druid.java.util.emitter.service.ServiceEmitter; -import io.druid.java.util.emitter.service.ServiceMetricEvent; import io.druid.indexing.common.TaskLock; import io.druid.indexing.common.TaskStatus; import io.druid.indexing.common.TaskToolbox; @@ -45,8 +41,11 @@ import io.druid.indexing.common.actions.TaskActionClient; import io.druid.java.util.common.DateTimes; import io.druid.java.util.common.ISE; import io.druid.java.util.common.StringUtils; -import io.druid.segment.writeout.SegmentWriteOutMediumFactory; +import io.druid.java.util.emitter.EmittingLogger; +import io.druid.java.util.emitter.service.ServiceEmitter; +import io.druid.java.util.emitter.service.ServiceMetricEvent; import io.druid.segment.IndexIO; +import io.druid.segment.writeout.SegmentWriteOutMediumFactory; import io.druid.timeline.DataSegment; import io.druid.timeline.partition.NoneShardSpec; import org.joda.time.DateTime; @@ -54,6 +53,7 @@ import org.joda.time.Interval; import javax.annotation.Nullable; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.Set; @@ -307,7 +307,7 @@ public abstract class MergeTaskBase extends AbstractFixedIntervalTask return StringUtils.format( "%s_%s", dataSource, - Hashing.sha1().hashString(segmentIDs, Charsets.UTF_8).toString() + Hashing.sha1().hashString(segmentIDs, StandardCharsets.UTF_8).toString() ); } diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java b/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java index 54427e435c2..ed7dbc3505d 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/RemoteTaskRunner.java @@ -21,7 +21,6 @@ package io.druid.indexing.overlord; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -92,6 +91,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -128,7 +128,7 @@ import java.util.concurrent.TimeUnit; public class RemoteTaskRunner implements WorkerTaskRunner, TaskLogStreamer { private static final EmittingLogger log = new EmittingLogger(RemoteTaskRunner.class); - private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(Charsets.UTF_8); + private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(StandardCharsets.UTF_8); private static final Joiner JOINER = Joiner.on("/"); private final ObjectMapper jsonMapper; diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/hrtr/WorkerHolder.java b/indexing-service/src/main/java/io/druid/indexing/overlord/hrtr/WorkerHolder.java index 199abb6821c..17fa67f7cec 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/hrtr/WorkerHolder.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/hrtr/WorkerHolder.java @@ -22,7 +22,6 @@ package io.druid.indexing.overlord.hrtr; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.Sets; @@ -50,6 +49,7 @@ import org.joda.time.DateTime; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -73,7 +73,7 @@ public class WorkerHolder { }; - private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(Charsets.UTF_8); + private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(StandardCharsets.UTF_8); private final Worker worker; private Worker disabledWorker; diff --git a/indexing-service/src/test/java/io/druid/indexing/common/task/MergeTaskBaseTest.java b/indexing-service/src/test/java/io/druid/indexing/common/task/MergeTaskBaseTest.java index a75b3fa45d5..aa43a153e9a 100644 --- a/indexing-service/src/test/java/io/druid/indexing/common/task/MergeTaskBaseTest.java +++ b/indexing-service/src/test/java/io/druid/indexing/common/task/MergeTaskBaseTest.java @@ -19,7 +19,6 @@ package io.druid.indexing.common.task; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.hash.Hashing; import io.druid.indexing.common.TaskToolbox; @@ -29,6 +28,7 @@ import org.junit.Assert; import org.junit.Test; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; @@ -80,7 +80,7 @@ public class MergeTaskBaseTest "2012-01-03T00:00:00.000Z_2012-01-05T00:00:00.000Z_V1_0" + "_2012-01-04T00:00:00.000Z_2012-01-06T00:00:00.000Z_V1_0" + "_2012-01-05T00:00:00.000Z_2012-01-07T00:00:00.000Z_V1_0", - Charsets.UTF_8 + StandardCharsets.UTF_8 ).toString() + "_"; Assert.assertEquals( diff --git a/indexing-service/src/test/java/io/druid/indexing/common/tasklogs/FileTaskLogsTest.java b/indexing-service/src/test/java/io/druid/indexing/common/tasklogs/FileTaskLogsTest.java index cb7b2282a68..717709d9724 100644 --- a/indexing-service/src/test/java/io/druid/indexing/common/tasklogs/FileTaskLogsTest.java +++ b/indexing-service/src/test/java/io/druid/indexing/common/tasklogs/FileTaskLogsTest.java @@ -19,7 +19,6 @@ package io.druid.indexing.common.tasklogs; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteStreams; import com.google.common.io.Files; @@ -35,6 +34,7 @@ import org.junit.rules.TemporaryFolder; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Map; public class FileTaskLogsTest @@ -53,7 +53,7 @@ public class FileTaskLogsTest try { final File logDir = new File(tmpDir, "druid/logs"); final File logFile = new File(tmpDir, "log"); - Files.write("blah", logFile, Charsets.UTF_8); + Files.write("blah", logFile, StandardCharsets.UTF_8); final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir)); taskLogs.pushTaskLog("foo", logFile); @@ -75,7 +75,7 @@ public class FileTaskLogsTest final File tmpDir = temporaryFolder.newFolder(); final File logDir = new File(tmpDir, "druid/logs"); final File logFile = new File(tmpDir, "log"); - Files.write("blah", logFile, Charsets.UTF_8); + Files.write("blah", logFile, StandardCharsets.UTF_8); if (!tmpDir.setWritable(false)) { throw new RuntimeException("failed to make tmp dir read-only"); @@ -96,7 +96,7 @@ public class FileTaskLogsTest final File logFile = new File(tmpDir, "log"); final TaskLogs taskLogs = new FileTaskLogs(new FileTaskLogsConfig(logDir)); - Files.write("log1content", logFile, Charsets.UTF_8); + Files.write("log1content", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("log1", logFile); Assert.assertEquals("log1content", readLog(taskLogs, "log1", 0)); @@ -107,7 +107,7 @@ public class FileTaskLogsTest long time = (System.currentTimeMillis() / 1000) * 1000; Assert.assertTrue(new File(logDir, "log1.log").lastModified() < time); - Files.write("log2content", logFile, Charsets.UTF_8); + Files.write("log2content", logFile, StandardCharsets.UTF_8); taskLogs.pushTaskLog("log2", logFile); Assert.assertEquals("log2content", readLog(taskLogs, "log2", 0)); Assert.assertTrue(new File(logDir, "log2.log").lastModified() >= time); diff --git a/integration-tests/src/main/java/io/druid/testing/clients/ClientInfoResourceTestClient.java b/integration-tests/src/main/java/io/druid/testing/clients/ClientInfoResourceTestClient.java index 65bccb904f5..ebda5570165 100644 --- a/integration-tests/src/main/java/io/druid/testing/clients/ClientInfoResourceTestClient.java +++ b/integration-tests/src/main/java/io/druid/testing/clients/ClientInfoResourceTestClient.java @@ -21,21 +21,21 @@ package io.druid.testing.clients; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Inject; +import io.druid.java.util.common.ISE; +import io.druid.java.util.common.StringUtils; import io.druid.java.util.http.client.HttpClient; import io.druid.java.util.http.client.Request; import io.druid.java.util.http.client.response.StatusResponseHandler; import io.druid.java.util.http.client.response.StatusResponseHolder; -import io.druid.java.util.common.ISE; -import io.druid.java.util.common.StringUtils; import io.druid.testing.IntegrationTestingConfig; import io.druid.testing.guice.TestClient; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.List; public class ClientInfoResourceTestClient @@ -55,7 +55,7 @@ public class ClientInfoResourceTestClient this.jsonMapper = jsonMapper; this.httpClient = httpClient; this.brokerUrl = config.getBrokerUrl(); - this.responseHandler = new StatusResponseHandler(Charsets.UTF_8); + this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); } private String getBrokerURL() diff --git a/integration-tests/src/main/java/io/druid/testing/clients/CoordinatorResourceTestClient.java b/integration-tests/src/main/java/io/druid/testing/clients/CoordinatorResourceTestClient.java index 003e76a1af2..fc9f009e135 100644 --- a/integration-tests/src/main/java/io/druid/testing/clients/CoordinatorResourceTestClient.java +++ b/integration-tests/src/main/java/io/druid/testing/clients/CoordinatorResourceTestClient.java @@ -21,7 +21,6 @@ package io.druid.testing.clients; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Inject; import io.druid.java.util.common.ISE; @@ -38,6 +37,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.joda.time.Interval; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -59,7 +59,7 @@ public class CoordinatorResourceTestClient this.jsonMapper = jsonMapper; this.httpClient = httpClient; this.coordinator = config.getCoordinatorUrl(); - this.responseHandler = new StatusResponseHandler(Charsets.UTF_8); + this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); } private String getCoordinatorURL() diff --git a/integration-tests/src/main/java/io/druid/testing/clients/EventReceiverFirehoseTestClient.java b/integration-tests/src/main/java/io/druid/testing/clients/EventReceiverFirehoseTestClient.java index 1cdb6a91ae7..697f24fdf51 100644 --- a/integration-tests/src/main/java/io/druid/testing/clients/EventReceiverFirehoseTestClient.java +++ b/integration-tests/src/main/java/io/druid/testing/clients/EventReceiverFirehoseTestClient.java @@ -22,15 +22,14 @@ package io.druid.testing.clients; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; +import io.druid.java.util.common.ISE; +import io.druid.java.util.common.StringUtils; +import io.druid.java.util.common.jackson.JacksonUtils; import io.druid.java.util.http.client.HttpClient; import io.druid.java.util.http.client.Request; import io.druid.java.util.http.client.response.StatusResponseHandler; import io.druid.java.util.http.client.response.StatusResponseHolder; -import io.druid.java.util.common.jackson.JacksonUtils; -import io.druid.java.util.common.ISE; -import io.druid.java.util.common.StringUtils; import io.druid.testing.guice.TestClient; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; @@ -63,7 +62,7 @@ public class EventReceiverFirehoseTestClient { this.host = host; this.jsonMapper = jsonMapper; - this.responseHandler = new StatusResponseHandler(Charsets.UTF_8); + this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); this.httpClient = httpClient; this.chatID = chatID; this.smileMapper = smileMapper; diff --git a/integration-tests/src/main/java/io/druid/testing/clients/OverlordResourceTestClient.java b/integration-tests/src/main/java/io/druid/testing/clients/OverlordResourceTestClient.java index 7062854e1f6..74162155e23 100644 --- a/integration-tests/src/main/java/io/druid/testing/clients/OverlordResourceTestClient.java +++ b/integration-tests/src/main/java/io/druid/testing/clients/OverlordResourceTestClient.java @@ -21,7 +21,6 @@ package io.druid.testing.clients; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Predicates; import com.google.common.base.Throwables; import com.google.inject.Inject; @@ -43,6 +42,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus; import java.net.URL; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.concurrent.Callable; @@ -65,7 +65,7 @@ public class OverlordResourceTestClient this.jsonMapper = jsonMapper; this.httpClient = httpClient; this.indexer = config.getIndexerUrl(); - this.responseHandler = new StatusResponseHandler(Charsets.UTF_8); + this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); } private String getIndexerURL() diff --git a/integration-tests/src/main/java/io/druid/testing/clients/QueryResourceTestClient.java b/integration-tests/src/main/java/io/druid/testing/clients/QueryResourceTestClient.java index b6a2c6bcce3..31d5aef0052 100644 --- a/integration-tests/src/main/java/io/druid/testing/clients/QueryResourceTestClient.java +++ b/integration-tests/src/main/java/io/druid/testing/clients/QueryResourceTestClient.java @@ -22,7 +22,6 @@ package io.druid.testing.clients; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Inject; import io.druid.java.util.http.client.HttpClient; @@ -38,6 +37,7 @@ import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; @@ -58,7 +58,7 @@ public class QueryResourceTestClient this.jsonMapper = jsonMapper; this.httpClient = httpClient; this.routerUrl = config.getRouterUrl(); - this.responseHandler = new StatusResponseHandler(Charsets.UTF_8); + this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); } private String getBrokerURL() diff --git a/integration-tests/src/main/java/org/testng/DruidTestRunnerFactory.java b/integration-tests/src/main/java/org/testng/DruidTestRunnerFactory.java index 939fc7ac7fb..1fb99144852 100644 --- a/integration-tests/src/main/java/org/testng/DruidTestRunnerFactory.java +++ b/integration-tests/src/main/java/org/testng/DruidTestRunnerFactory.java @@ -19,17 +19,16 @@ package org.testng; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Injector; import com.google.inject.Key; +import io.druid.java.util.common.StringUtils; +import io.druid.java.util.common.lifecycle.Lifecycle; +import io.druid.java.util.common.logger.Logger; import io.druid.java.util.http.client.HttpClient; import io.druid.java.util.http.client.Request; import io.druid.java.util.http.client.response.StatusResponseHandler; import io.druid.java.util.http.client.response.StatusResponseHolder; -import io.druid.java.util.common.StringUtils; -import io.druid.java.util.common.lifecycle.Lifecycle; -import io.druid.java.util.common.logger.Logger; import io.druid.testing.IntegrationTestingConfig; import io.druid.testing.guice.DruidTestModuleFactory; import io.druid.testing.guice.TestClient; @@ -41,6 +40,7 @@ import org.testng.internal.annotations.IAnnotationFinder; import org.testng.xml.XmlTest; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.List; public class DruidTestRunnerFactory implements ITestRunnerFactory @@ -117,7 +117,7 @@ public class DruidTestRunnerFactory implements ITestRunnerFactory public void waitUntilInstanceReady(final HttpClient client, final String host) { - final StatusResponseHandler handler = new StatusResponseHandler(Charsets.UTF_8); + final StatusResponseHandler handler = new StatusResponseHandler(StandardCharsets.UTF_8); RetryUtil.retryUntilTrue( () -> { try { diff --git a/integration-tests/src/test/java/io/druid/tests/security/ITBasicAuthConfigurationTest.java b/integration-tests/src/test/java/io/druid/tests/security/ITBasicAuthConfigurationTest.java index dd9344846f1..c4d3b41e908 100644 --- a/integration-tests/src/test/java/io/druid/tests/security/ITBasicAuthConfigurationTest.java +++ b/integration-tests/src/test/java/io/druid/tests/security/ITBasicAuthConfigurationTest.java @@ -21,19 +21,18 @@ package io.druid.tests.security; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Inject; +import io.druid.guice.annotations.Client; +import io.druid.java.util.common.ISE; +import io.druid.java.util.common.StringUtils; +import io.druid.java.util.common.logger.Logger; import io.druid.java.util.http.client.CredentialedHttpClient; import io.druid.java.util.http.client.HttpClient; import io.druid.java.util.http.client.Request; import io.druid.java.util.http.client.auth.BasicCredentials; import io.druid.java.util.http.client.response.StatusResponseHandler; import io.druid.java.util.http.client.response.StatusResponseHolder; -import io.druid.guice.annotations.Client; -import io.druid.java.util.common.ISE; -import io.druid.java.util.common.StringUtils; -import io.druid.java.util.common.logger.Logger; import io.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate; import io.druid.server.security.Action; import io.druid.server.security.Resource; @@ -51,6 +50,7 @@ import org.testng.annotations.Test; import javax.ws.rs.core.MediaType; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; @@ -80,7 +80,7 @@ public class ITBasicAuthConfigurationTest @Client HttpClient httpClient; - StatusResponseHandler responseHandler = new StatusResponseHandler(Charsets.UTF_8); + StatusResponseHandler responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8); @Test public void testAuthConfiguration() throws Exception diff --git a/java-util/src/main/java/io/druid/java/util/common/StringUtils.java b/java-util/src/main/java/io/druid/java/util/common/StringUtils.java index d073ef38b42..16830e1b20f 100644 --- a/java-util/src/main/java/io/druid/java/util/common/StringUtils.java +++ b/java-util/src/main/java/io/druid/java/util/common/StringUtils.java @@ -19,13 +19,13 @@ package io.druid.java.util.common; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import javax.annotation.Nullable; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.IllegalFormatException; import java.util.Locale; @@ -37,8 +37,8 @@ public class StringUtils { public static final byte[] EMPTY_BYTES = new byte[0]; @Deprecated // Charset parameters to String are currently slower than the charset's string name - public static final Charset UTF8_CHARSET = Charsets.UTF_8; - public static final String UTF8_STRING = Charsets.UTF_8.toString(); + public static final Charset UTF8_CHARSET = StandardCharsets.UTF_8; + public static final String UTF8_STRING = StandardCharsets.UTF_8.toString(); // should be used only for estimation // returns the same result with StringUtils.fromUtf8(value).length for valid string values diff --git a/java-util/src/main/java/io/druid/java/util/common/io/smoosh/FileSmoosher.java b/java-util/src/main/java/io/druid/java/util/common/io/smoosh/FileSmoosher.java index b928bbba566..1e06098426f 100644 --- a/java-util/src/main/java/io/druid/java/util/common/io/smoosh/FileSmoosher.java +++ b/java-util/src/main/java/io/druid/java/util/common/io/smoosh/FileSmoosher.java @@ -19,7 +19,6 @@ package io.druid.java.util.common.io.smoosh; -import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; @@ -45,6 +44,7 @@ import java.io.Writer; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.channels.GatheringByteChannel; +import java.nio.charset.StandardCharsets; import java.nio.file.StandardOpenOption; import java.util.ArrayList; import java.util.Collections; @@ -370,7 +370,7 @@ public class FileSmoosher implements Closeable File metaFile = metaFile(baseDir); - try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metaFile), Charsets.UTF_8))) { + try (Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(metaFile), StandardCharsets.UTF_8))) { out.write(StringUtils.format("v1,%d,%d", maxChunkSize, outFiles.size())); out.write("\n"); diff --git a/java-util/src/main/java/io/druid/java/util/common/io/smoosh/SmooshedFileMapper.java b/java-util/src/main/java/io/druid/java/util/common/io/smoosh/SmooshedFileMapper.java index bb95dce7dc9..38d79888a40 100644 --- a/java-util/src/main/java/io/druid/java/util/common/io/smoosh/SmooshedFileMapper.java +++ b/java-util/src/main/java/io/druid/java/util/common/io/smoosh/SmooshedFileMapper.java @@ -19,7 +19,6 @@ package io.druid.java.util.common.io.smoosh; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -36,6 +35,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; import java.util.Set; @@ -52,7 +52,7 @@ public class SmooshedFileMapper implements Closeable BufferedReader in = null; try { - in = new BufferedReader(new InputStreamReader(new FileInputStream(metaFile), Charsets.UTF_8)); + in = new BufferedReader(new InputStreamReader(new FileInputStream(metaFile), StandardCharsets.UTF_8)); String line = in.readLine(); if (line == null) { diff --git a/java-util/src/main/java/io/druid/java/util/common/parsers/JSONFlattenerMaker.java b/java-util/src/main/java/io/druid/java/util/common/parsers/JSONFlattenerMaker.java index 5f1c6736a02..06f290ac7c1 100644 --- a/java-util/src/main/java/io/druid/java/util/common/parsers/JSONFlattenerMaker.java +++ b/java-util/src/main/java/io/druid/java/util/common/parsers/JSONFlattenerMaker.java @@ -20,7 +20,6 @@ package io.druid.java.util.common.parsers; import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.base.Charsets; import com.google.common.collect.FluentIterable; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; @@ -33,6 +32,7 @@ import net.thisptr.jackson.jq.exception.JsonQueryException; import javax.annotation.Nullable; import java.nio.charset.CharsetEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.EnumSet; import java.util.Iterator; @@ -50,7 +50,7 @@ public class JSONFlattenerMaker implements ObjectFlatteners.FlattenerMaker discoverRootFields(final JsonNode obj) diff --git a/java-util/src/main/java/io/druid/java/util/common/parsers/JSONToLowerParser.java b/java-util/src/main/java/io/druid/java/util/common/parsers/JSONToLowerParser.java index 5a04d9b75bf..f647f39eb35 100644 --- a/java-util/src/main/java/io/druid/java/util/common/parsers/JSONToLowerParser.java +++ b/java-util/src/main/java/io/druid/java/util/common/parsers/JSONToLowerParser.java @@ -21,7 +21,6 @@ package io.druid.java.util.common.parsers; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -29,6 +28,7 @@ import com.google.common.collect.Sets; import io.druid.java.util.common.StringUtils; import java.nio.charset.CharsetEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; @@ -65,7 +65,7 @@ public class JSONToLowerParser implements Parser return node.asDouble(); } final String s = node.asText(); - final CharsetEncoder enc = Charsets.UTF_8.newEncoder(); + final CharsetEncoder enc = StandardCharsets.UTF_8.newEncoder(); if (s != null && !enc.canEncode(s)) { // Some whacky characters are in this string (e.g. \uD900). These are problematic because they are decodeable // by new String(...) but will not encode into the same character. This dance here will replace these diff --git a/java-util/src/main/java/io/druid/java/util/http/client/Request.java b/java-util/src/main/java/io/druid/java/util/http/client/Request.java index a67270de55b..161315ca78c 100644 --- a/java-util/src/main/java/io/druid/java/util/http/client/Request.java +++ b/java-util/src/main/java/io/druid/java/util/http/client/Request.java @@ -19,7 +19,6 @@ package io.druid.java.util.http.client; -import com.google.common.base.Charsets; import com.google.common.base.Supplier; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -35,6 +34,7 @@ import org.jboss.netty.handler.codec.http.HttpMethod; import java.net.URL; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -175,7 +175,7 @@ public class Request final ChannelBufferFactory bufferFactory = HeapChannelBufferFactory.getInstance(); return Base64 - .encode(bufferFactory.getBuffer(ByteBuffer.wrap(value.getBytes(Charsets.UTF_8))), false) - .toString(Charsets.UTF_8); + .encode(bufferFactory.getBuffer(ByteBuffer.wrap(value.getBytes(StandardCharsets.UTF_8))), false) + .toString(StandardCharsets.UTF_8); } } diff --git a/java-util/src/main/java/io/druid/java/util/metrics/cgroups/CpuAcct.java b/java-util/src/main/java/io/druid/java/util/metrics/cgroups/CpuAcct.java index ad0ceb53525..ab789e0eef0 100644 --- a/java-util/src/main/java/io/druid/java/util/metrics/cgroups/CpuAcct.java +++ b/java-util/src/main/java/io/druid/java/util/metrics/cgroups/CpuAcct.java @@ -19,7 +19,6 @@ package io.druid.java.util.metrics.cgroups; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import io.druid.java.util.common.RE; import io.druid.java.util.common.logger.Logger; @@ -27,6 +26,7 @@ import io.druid.java.util.metrics.CgroupUtil; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; import java.util.stream.LongStream; @@ -83,7 +83,7 @@ public class CpuAcct return new CpuAcctMetric(new long[0], new long[0]); } try { - return parse(Files.readAllLines(cpuacct.toPath(), Charsets.UTF_8)); + return parse(Files.readAllLines(cpuacct.toPath(), StandardCharsets.UTF_8)); } catch (IOException e) { throw new RuntimeException(e); diff --git a/java-util/src/main/java/io/druid/java/util/metrics/cgroups/ProcCgroupDiscoverer.java b/java-util/src/main/java/io/druid/java/util/metrics/cgroups/ProcCgroupDiscoverer.java index 619a8e6f686..36d66ff866a 100644 --- a/java-util/src/main/java/io/druid/java/util/metrics/cgroups/ProcCgroupDiscoverer.java +++ b/java-util/src/main/java/io/druid/java/util/metrics/cgroups/ProcCgroupDiscoverer.java @@ -19,7 +19,6 @@ package io.druid.java.util.metrics.cgroups; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import com.google.common.io.Files; @@ -28,6 +27,7 @@ import io.druid.java.util.metrics.CgroupUtil; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; @@ -76,7 +76,7 @@ public class ProcCgroupDiscoverer implements CgroupDiscoverer { final List lines; try { - lines = Files.readLines(procCgroup, Charsets.UTF_8); + lines = Files.readLines(procCgroup, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); @@ -97,7 +97,7 @@ public class ProcCgroupDiscoverer implements CgroupDiscoverer { final List lines; try { - lines = Files.readLines(procMounts, Charsets.UTF_8); + lines = Files.readLines(procMounts, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException(e); diff --git a/java-util/src/test/java/io/druid/java/util/emitter/core/EmitterTest.java b/java-util/src/test/java/io/druid/java/util/emitter/core/EmitterTest.java index 2653ba817cf..78e6c0698b2 100644 --- a/java-util/src/test/java/io/druid/java/util/emitter/core/EmitterTest.java +++ b/java-util/src/test/java/io/druid/java/util/emitter/core/EmitterTest.java @@ -21,7 +21,6 @@ package io.druid.java.util.emitter.core; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.io.BaseEncoding; import io.druid.java.util.common.CompressionUtils; import io.druid.java.util.common.StringUtils; @@ -229,7 +228,7 @@ public class EmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); @@ -271,7 +270,7 @@ public class EmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); @@ -450,7 +449,7 @@ public class EmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); @@ -502,7 +501,7 @@ public class EmitterTest jsonMapper.writeValueAsString(events.get(counter.getAndIncrement())), jsonMapper.writeValueAsString(events.get(counter.getAndIncrement())) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); @@ -561,7 +560,7 @@ public class EmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - baos.toString(Charsets.UTF_8.name()) + baos.toString(StandardCharsets.UTF_8.name()) ); return GoHandlers.immediateFuture(okResponse()); diff --git a/java-util/src/test/java/io/druid/java/util/emitter/core/ParametrizedUriEmitterTest.java b/java-util/src/test/java/io/druid/java/util/emitter/core/ParametrizedUriEmitterTest.java index e9124e8f96a..97a14ef5e6a 100644 --- a/java-util/src/test/java/io/druid/java/util/emitter/core/ParametrizedUriEmitterTest.java +++ b/java-util/src/test/java/io/druid/java/util/emitter/core/ParametrizedUriEmitterTest.java @@ -21,7 +21,6 @@ package io.druid.java.util.emitter.core; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import io.druid.java.util.common.StringUtils; import io.druid.java.util.common.lifecycle.Lifecycle; @@ -34,6 +33,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -104,7 +104,7 @@ public class ParametrizedUriEmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); @@ -138,7 +138,7 @@ public class ParametrizedUriEmitterTest { results.put( request.getUrl().toString(), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); } @@ -178,7 +178,7 @@ public class ParametrizedUriEmitterTest jsonMapper.writeValueAsString(events.get(0)), jsonMapper.writeValueAsString(events.get(1)) ), - Charsets.UTF_8.decode(request.getByteBufferData().slice()).toString() + StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString() ); return GoHandlers.immediateFuture(okResponse()); diff --git a/java-util/src/test/java/io/druid/java/util/http/client/AsyncHttpClientTest.java b/java-util/src/test/java/io/druid/java/util/http/client/AsyncHttpClientTest.java index 5650fc61976..f0a576a6980 100644 --- a/java-util/src/test/java/io/druid/java/util/http/client/AsyncHttpClientTest.java +++ b/java-util/src/test/java/io/druid/java/util/http/client/AsyncHttpClientTest.java @@ -19,7 +19,6 @@ package io.druid.java.util.http.client; -import com.google.common.base.Charsets; import io.druid.java.util.common.StringUtils; import org.asynchttpclient.DefaultAsyncHttpClient; import org.junit.Assert; @@ -64,7 +63,7 @@ public class AsyncHttpClientTest // skip lines } Thread.sleep(5000); // times out - out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(Charsets.UTF_8)); + out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(StandardCharsets.UTF_8)); } catch (Exception e) { // Suppress diff --git a/java-util/src/test/java/io/druid/java/util/http/client/FriendlyServersTest.java b/java-util/src/test/java/io/druid/java/util/http/client/FriendlyServersTest.java index 1496c904bd9..fb9d0430c05 100644 --- a/java-util/src/test/java/io/druid/java/util/http/client/FriendlyServersTest.java +++ b/java-util/src/test/java/io/druid/java/util/http/client/FriendlyServersTest.java @@ -19,7 +19,6 @@ package io.druid.java.util.http.client; -import com.google.common.base.Charsets; import com.google.common.util.concurrent.ListenableFuture; import io.druid.java.util.common.StringUtils; import io.druid.java.util.common.lifecycle.Lifecycle; @@ -81,7 +80,7 @@ public class FriendlyServersTest while (!in.readLine().equals("")) { // skip lines } - out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(Charsets.UTF_8)); + out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(StandardCharsets.UTF_8)); } catch (Exception e) { // Suppress @@ -98,7 +97,7 @@ public class FriendlyServersTest final StatusResponseHolder response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ).get(); Assert.assertEquals(200, response.getStatus().getCode()); @@ -138,7 +137,7 @@ public class FriendlyServersTest foundAcceptEncoding.set(true); } } - out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(Charsets.UTF_8)); + out.write("HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nhello!".getBytes(StandardCharsets.UTF_8)); } catch (Exception e) { // Suppress @@ -157,7 +156,7 @@ public class FriendlyServersTest final StatusResponseHolder response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ).get(); Assert.assertEquals(200, response.getStatus().getCode()); @@ -214,7 +213,7 @@ public class FriendlyServersTest HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", sslConnector.getLocalPort())) ), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ).get().getStatus(); Assert.assertEquals(404, status.getCode()); } @@ -227,7 +226,7 @@ public class FriendlyServersTest HttpMethod.GET, new URL(StringUtils.format("https://127.0.0.1:%d/", sslConnector.getLocalPort())) ), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable ea = null; @@ -249,7 +248,7 @@ public class FriendlyServersTest new Request( HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", sslConnector.getLocalPort())) ), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable eb = null; @@ -285,7 +284,7 @@ public class FriendlyServersTest final HttpResponseStatus status = client .go( new Request(HttpMethod.GET, new URL("https://httpbin.org/get")), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ).get().getStatus(); Assert.assertEquals(200, status.getCode()); @@ -296,7 +295,7 @@ public class FriendlyServersTest .go( new Request(HttpMethod.POST, new URL("https://httpbin.org/post")) .setContent(new byte[]{'a', 'b', 'c', 1, 2, 3}), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ).get().getStatus(); Assert.assertEquals(200, status.getCode()); diff --git a/java-util/src/test/java/io/druid/java/util/http/client/JankyServersTest.java b/java-util/src/test/java/io/druid/java/util/http/client/JankyServersTest.java index 1923ba9fb6b..b75da694eba 100644 --- a/java-util/src/test/java/io/druid/java/util/http/client/JankyServersTest.java +++ b/java-util/src/test/java/io/druid/java/util/http/client/JankyServersTest.java @@ -19,7 +19,6 @@ package io.druid.java.util.http.client; -import com.google.common.base.Charsets; import com.google.common.util.concurrent.ListenableFuture; import io.druid.java.util.common.StringUtils; import io.druid.java.util.common.lifecycle.Lifecycle; @@ -41,6 +40,7 @@ import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -153,7 +153,7 @@ public class JankyServersTest final ListenableFuture future = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; @@ -181,7 +181,7 @@ public class JankyServersTest final ListenableFuture future = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8), + new StatusResponseHandler(StandardCharsets.UTF_8), new Duration(100L) ); @@ -214,7 +214,7 @@ public class JankyServersTest final ListenableFuture response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", silentServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; @@ -242,7 +242,7 @@ public class JankyServersTest final ListenableFuture response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", closingServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; try { @@ -271,7 +271,7 @@ public class JankyServersTest final ListenableFuture response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", closingServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; @@ -306,7 +306,7 @@ public class JankyServersTest final ListenableFuture response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", echoServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; @@ -336,7 +336,7 @@ public class JankyServersTest final ListenableFuture response = client .go( new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", echoServerSocket.getLocalPort()))), - new StatusResponseHandler(Charsets.UTF_8) + new StatusResponseHandler(StandardCharsets.UTF_8) ); Throwable e = null; diff --git a/processing/src/main/java/io/druid/guice/PropertiesModule.java b/processing/src/main/java/io/druid/guice/PropertiesModule.java index 1d838f24576..905c1c867d0 100644 --- a/processing/src/main/java/io/druid/guice/PropertiesModule.java +++ b/processing/src/main/java/io/druid/guice/PropertiesModule.java @@ -19,7 +19,6 @@ package io.druid.guice; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.inject.Binder; import com.google.inject.Module; @@ -33,6 +32,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Properties; @@ -71,7 +71,7 @@ public class PropertiesModule implements Module if (stream != null) { log.info("Loading properties from %s", propertiesFile); try { - fileProps.load(new InputStreamReader(stream, Charsets.UTF_8)); + fileProps.load(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (IOException e) { throw Throwables.propagate(e); diff --git a/processing/src/test/java/io/druid/segment/TestIndex.java b/processing/src/test/java/io/druid/segment/TestIndex.java index a6b03a6dd0d..970403fabf1 100644 --- a/processing/src/test/java/io/druid/segment/TestIndex.java +++ b/processing/src/test/java/io/druid/segment/TestIndex.java @@ -19,7 +19,6 @@ package io.druid.segment; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.common.io.CharSource; import com.google.common.io.LineProcessor; @@ -37,7 +36,6 @@ import io.druid.hll.HyperLogLogHash; import io.druid.java.util.common.DateTimes; import io.druid.java.util.common.Intervals; import io.druid.java.util.common.logger.Logger; -import io.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import io.druid.query.aggregation.AggregatorFactory; import io.druid.query.aggregation.DoubleMaxAggregatorFactory; import io.druid.query.aggregation.DoubleMinAggregatorFactory; @@ -53,11 +51,13 @@ import io.druid.segment.incremental.IncrementalIndex; import io.druid.segment.incremental.IncrementalIndexSchema; import io.druid.segment.serde.ComplexMetrics; import io.druid.segment.virtual.ExpressionVirtualColumn; +import io.druid.segment.writeout.OffHeapMemorySegmentWriteOutMediumFactory; import org.joda.time.Interval; import java.io.File; import java.io.IOException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -261,7 +261,7 @@ public class TestIndex throw new IllegalArgumentException("cannot find resource " + resourceFilename); } log.info("Realtime loading index file[%s]", resource); - CharSource stream = Resources.asByteSource(resource).asCharSource(Charsets.UTF_8); + CharSource stream = Resources.asByteSource(resource).asCharSource(StandardCharsets.UTF_8); return makeRealtimeIndex(stream, rollup); } diff --git a/server/src/main/java/io/druid/client/CachingClusteredClient.java b/server/src/main/java/io/druid/client/CachingClusteredClient.java index df48cc0f21e..2be0a819a35 100644 --- a/server/src/main/java/io/druid/client/CachingClusteredClient.java +++ b/server/src/main/java/io/druid/client/CachingClusteredClient.java @@ -21,7 +21,6 @@ package io.druid.client; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; @@ -81,6 +80,7 @@ import org.joda.time.Interval; import javax.annotation.Nullable; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -382,7 +382,7 @@ public class CachingClusteredClient implements QuerySegmentWalker hasOnlyHistoricalSegments = false; break; } - hasher.putString(p.getServer().getSegment().getIdentifier(), Charsets.UTF_8); + hasher.putString(p.getServer().getSegment().getIdentifier(), StandardCharsets.UTF_8); } if (hasOnlyHistoricalSegments) { diff --git a/server/src/main/java/io/druid/client/DirectDruidClient.java b/server/src/main/java/io/druid/client/DirectDruidClient.java index d34efee089d..8db791b1c9b 100644 --- a/server/src/main/java/io/druid/client/DirectDruidClient.java +++ b/server/src/main/java/io/druid/client/DirectDruidClient.java @@ -27,19 +27,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.common.io.ByteSource; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import io.druid.java.util.emitter.service.ServiceEmitter; -import io.druid.java.util.http.client.HttpClient; -import io.druid.java.util.http.client.Request; -import io.druid.java.util.http.client.response.ClientResponse; -import io.druid.java.util.http.client.response.HttpResponseHandler; -import io.druid.java.util.http.client.response.StatusResponseHandler; -import io.druid.java.util.http.client.response.StatusResponseHolder; import io.druid.java.util.common.IAE; import io.druid.java.util.common.Pair; import io.druid.java.util.common.RE; @@ -50,6 +42,13 @@ import io.druid.java.util.common.guava.Sequence; import io.druid.java.util.common.guava.Sequences; import io.druid.java.util.common.jackson.JacksonUtils; import io.druid.java.util.common.logger.Logger; +import io.druid.java.util.emitter.service.ServiceEmitter; +import io.druid.java.util.http.client.HttpClient; +import io.druid.java.util.http.client.Request; +import io.druid.java.util.http.client.response.ClientResponse; +import io.druid.java.util.http.client.response.HttpResponseHandler; +import io.druid.java.util.http.client.response.StatusResponseHandler; +import io.druid.java.util.http.client.response.StatusResponseHolder; import io.druid.query.BySegmentResultValueClass; import io.druid.query.Query; import io.druid.query.QueryContexts; @@ -77,6 +76,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.SequenceInputStream; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Enumeration; import java.util.Iterator; import java.util.Map; @@ -480,7 +480,7 @@ public class DirectDruidClient implements QueryRunner ? SmileMediaTypes.APPLICATION_JACKSON_SMILE : MediaType.APPLICATION_JSON ), - new StatusResponseHandler(Charsets.UTF_8), + new StatusResponseHandler(StandardCharsets.UTF_8), Duration.standardSeconds(1) ).get(1, TimeUnit.SECONDS); diff --git a/server/src/main/java/io/druid/client/cache/MemcachedCache.java b/server/src/main/java/io/druid/client/cache/MemcachedCache.java index 02379124223..7010134b2da 100644 --- a/server/src/main/java/io/druid/client/cache/MemcachedCache.java +++ b/server/src/main/java/io/druid/client/cache/MemcachedCache.java @@ -19,7 +19,6 @@ package io.druid.client.cache; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; @@ -56,6 +55,7 @@ import javax.annotation.Nullable; import java.io.IOException; import java.net.InetSocketAddress; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -87,7 +87,7 @@ public class MemcachedCache implements Cache @Override public long hash(String k) { - return fn.hashString(k, Charsets.UTF_8).asLong(); + return fn.hashString(k, StandardCharsets.UTF_8).asLong(); } @Override diff --git a/server/src/main/java/io/druid/discovery/DruidLeaderClient.java b/server/src/main/java/io/druid/discovery/DruidLeaderClient.java index a77b8312937..c1c4dbcaa30 100644 --- a/server/src/main/java/io/druid/discovery/DruidLeaderClient.java +++ b/server/src/main/java/io/druid/discovery/DruidLeaderClient.java @@ -19,14 +19,8 @@ package io.druid.discovery; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; -import io.druid.java.util.http.client.HttpClient; -import io.druid.java.util.http.client.Request; -import io.druid.java.util.http.client.response.FullResponseHandler; -import io.druid.java.util.http.client.response.FullResponseHolder; -import io.druid.java.util.http.client.response.HttpResponseHandler; import io.druid.client.selector.Server; import io.druid.concurrent.LifecycleLock; import io.druid.curator.discovery.ServerDiscoverySelector; @@ -37,6 +31,11 @@ import io.druid.java.util.common.StringUtils; import io.druid.java.util.common.lifecycle.LifecycleStart; import io.druid.java.util.common.lifecycle.LifecycleStop; import io.druid.java.util.common.logger.Logger; +import io.druid.java.util.http.client.HttpClient; +import io.druid.java.util.http.client.Request; +import io.druid.java.util.http.client.response.FullResponseHandler; +import io.druid.java.util.http.client.response.FullResponseHolder; +import io.druid.java.util.http.client.response.HttpResponseHandler; import org.jboss.netty.channel.ChannelException; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpResponseStatus; @@ -45,6 +44,7 @@ import javax.annotation.Nullable; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -130,7 +130,7 @@ public class DruidLeaderClient public FullResponseHolder go(Request request) throws IOException, InterruptedException { - return go(request, new FullResponseHandler(Charsets.UTF_8)); + return go(request, new FullResponseHandler(StandardCharsets.UTF_8)); } /** diff --git a/server/src/main/java/io/druid/server/log/FileRequestLogger.java b/server/src/main/java/io/druid/server/log/FileRequestLogger.java index db86c29beb9..cb0edc795cd 100644 --- a/server/src/main/java/io/druid/server/log/FileRequestLogger.java +++ b/server/src/main/java/io/druid/server/log/FileRequestLogger.java @@ -20,7 +20,6 @@ package io.druid.server.log; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.base.Throwables; import io.druid.java.util.common.DateTimes; import io.druid.java.util.common.StringUtils; @@ -39,6 +38,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; @@ -112,7 +112,7 @@ public class FileRequestLogger implements RequestLogger { return new OutputStreamWriter( new FileOutputStream(new File(baseDir, currentDay.toString("yyyy-MM-dd'.log'")), true), - Charsets.UTF_8 + StandardCharsets.UTF_8 ); } diff --git a/server/src/main/java/io/druid/server/router/ConsistentHasher.java b/server/src/main/java/io/druid/server/router/ConsistentHasher.java index f3fee3024be..253e46bf0ae 100644 --- a/server/src/main/java/io/druid/server/router/ConsistentHasher.java +++ b/server/src/main/java/io/druid/server/router/ConsistentHasher.java @@ -19,13 +19,13 @@ package io.druid.server.router; -import com.google.common.base.Charsets; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectRBTreeMap; import it.unimi.dsi.fastutil.longs.Long2ObjectSortedMap; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -119,7 +119,7 @@ public class ConsistentHasher long[] hashes = new long[REPLICATION_FACTOR]; for (int i = 0; i < REPLICATION_FACTOR; i++) { String vnode = key + "-" + i; - hashes[i] = hashFn.hashString(vnode, Charsets.UTF_8).asLong(); + hashes[i] = hashFn.hashString(vnode, StandardCharsets.UTF_8).asLong(); } nodeKeyHashes.put(key, hashes); diff --git a/server/src/main/java/io/druid/server/router/RendezvousHasher.java b/server/src/main/java/io/druid/server/router/RendezvousHasher.java index 170573ef2d9..0aab0bec33b 100644 --- a/server/src/main/java/io/druid/server/router/RendezvousHasher.java +++ b/server/src/main/java/io/druid/server/router/RendezvousHasher.java @@ -19,12 +19,12 @@ package io.druid.server.router; -import com.google.common.base.Charsets; import com.google.common.collect.Lists; import com.google.common.hash.HashCode; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Set; @@ -47,7 +47,7 @@ public class RendezvousHasher String maxNode = null; for (String nodeId : nodeIds) { - HashCode nodeHash = HASH_FN.hashString(nodeId, Charsets.UTF_8); + HashCode nodeHash = HASH_FN.hashString(nodeId, StandardCharsets.UTF_8); List hashes = Lists.newArrayList(nodeHash, keyHash); long combinedHash = Hashing.combineOrdered(hashes).asLong(); if (maxNode == null) { diff --git a/server/src/test/java/io/druid/client/CachingClusteredClientTest.java b/server/src/test/java/io/druid/client/CachingClusteredClientTest.java index 25901cfeffb..39ec5f1e5e1 100644 --- a/server/src/test/java/io/druid/client/CachingClusteredClientTest.java +++ b/server/src/test/java/io/druid/client/CachingClusteredClientTest.java @@ -22,7 +22,6 @@ package io.druid.client; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.dataformat.smile.SmileFactory; -import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.base.Supplier; @@ -150,6 +149,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import javax.annotation.Nullable; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -1470,8 +1470,8 @@ public class CachingClusteredClientTest .setContext(CONTEXT); final HyperLogLogCollector collector = HyperLogLogCollector.makeLatestCollector(); - collector.add(hashFn.hashString("abc123", Charsets.UTF_8).asBytes()); - collector.add(hashFn.hashString("123abc", Charsets.UTF_8).asBytes()); + collector.add(hashFn.hashString("abc123", StandardCharsets.UTF_8).asBytes()); + collector.add(hashFn.hashString("123abc", StandardCharsets.UTF_8).asBytes()); testQueryCaching( getDefaultQueryRunner(), diff --git a/server/src/test/java/io/druid/segment/indexing/DataSchemaTest.java b/server/src/test/java/io/druid/segment/indexing/DataSchemaTest.java index 86da576fb4e..9dd8f07cf2f 100644 --- a/server/src/test/java/io/druid/segment/indexing/DataSchemaTest.java +++ b/server/src/test/java/io/druid/segment/indexing/DataSchemaTest.java @@ -21,7 +21,6 @@ package io.druid.segment.indexing; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import io.druid.data.input.InputRow; @@ -50,6 +49,7 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Map; @@ -170,7 +170,7 @@ public class DataSchemaTest final StringInputRowParser parser = (StringInputRowParser) schema.getParser(); final InputRow row1bb = parser.parseBatch( - ByteBuffer.wrap("{\"time\":\"2000-01-01\",\"dimA\":\"foo\"}".getBytes(Charsets.UTF_8)) + ByteBuffer.wrap("{\"time\":\"2000-01-01\",\"dimA\":\"foo\"}".getBytes(StandardCharsets.UTF_8)) ).get(0); Assert.assertEquals(DateTimes.of("2000-01-01"), row1bb.getTimestamp()); Assert.assertEquals("foo", row1bb.getRaw("dimA")); @@ -182,7 +182,7 @@ public class DataSchemaTest Assert.assertEquals("foofoo", row1string.getRaw("expr")); final InputRow row2 = parser.parseBatch( - ByteBuffer.wrap("{\"time\":\"2000-01-01\",\"dimA\":\"x\"}".getBytes(Charsets.UTF_8)) + ByteBuffer.wrap("{\"time\":\"2000-01-01\",\"dimA\":\"x\"}".getBytes(StandardCharsets.UTF_8)) ).get(0); Assert.assertNull(row2); } diff --git a/server/src/test/java/io/druid/segment/realtime/firehose/IngestSegmentFirehoseTest.java b/server/src/test/java/io/druid/segment/realtime/firehose/IngestSegmentFirehoseTest.java index 4b363080659..52a15025680 100644 --- a/server/src/test/java/io/druid/segment/realtime/firehose/IngestSegmentFirehoseTest.java +++ b/server/src/test/java/io/druid/segment/realtime/firehose/IngestSegmentFirehoseTest.java @@ -19,7 +19,6 @@ package io.druid.segment.realtime.firehose; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import io.druid.collections.spatial.search.RadiusBound; @@ -59,6 +58,7 @@ import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.List; @@ -212,7 +212,7 @@ public class IngestSegmentFirehoseTest false, 0 ), - Charsets.UTF_8.toString() + StandardCharsets.UTF_8.toString() ); try ( diff --git a/server/src/test/java/io/druid/segment/realtime/firehose/LocalFirehoseFactoryTest.java b/server/src/test/java/io/druid/segment/realtime/firehose/LocalFirehoseFactoryTest.java index ccd00941b23..436272c1f06 100644 --- a/server/src/test/java/io/druid/segment/realtime/firehose/LocalFirehoseFactoryTest.java +++ b/server/src/test/java/io/druid/segment/realtime/firehose/LocalFirehoseFactoryTest.java @@ -19,7 +19,6 @@ package io.druid.segment.realtime.firehose; -import com.google.common.base.Charsets; import com.google.common.collect.Lists; import io.druid.data.input.Firehose; import io.druid.data.input.Row; @@ -89,7 +88,7 @@ public class LocalFirehoseFactoryTest false, 0 ), - Charsets.UTF_8.name() + StandardCharsets.UTF_8.name() ), null)) { final List rows = new ArrayList<>(); while (firehose.hasMore()) { diff --git a/server/src/test/java/io/druid/server/log/LoggingRequestLoggerTest.java b/server/src/test/java/io/druid/server/log/LoggingRequestLoggerTest.java index bdcb0ded63c..53dec6a6d0c 100644 --- a/server/src/test/java/io/druid/server/log/LoggingRequestLoggerTest.java +++ b/server/src/test/java/io/druid/server/log/LoggingRequestLoggerTest.java @@ -21,7 +21,6 @@ package io.druid.server.log; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableMap; import io.druid.jackson.DefaultObjectMapper; import io.druid.java.util.common.DateTimes; @@ -51,6 +50,7 @@ import org.junit.BeforeClass; import org.junit.Test; import java.io.ByteArrayOutputStream; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -99,7 +99,7 @@ public class LoggingRequestLoggerTest .newBuilder() .setName("test stream") .setTarget(baos) - .setLayout(JsonLayout.createLayout(false, true, false, true, true, Charsets.UTF_8)) + .setLayout(JsonLayout.createLayout(false, true, false, true, true, StandardCharsets.UTF_8)) .build(); final Logger logger = (Logger) LogManager.getLogger(LoggingRequestLogger.class);