Replace guava Charsets with native java StandardCharsets (#5545)

This commit is contained in:
Kirill Kozlov 2018-03-29 06:00:08 +02:00 committed by Jihoon Son
parent 81be1b3966
commit 8878a7ff94
53 changed files with 165 additions and 172 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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

View File

@ -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()
com.google.common.collect.Iterators#emptyIterator() @ Use java.util.Collections#emptyIterator()
com.google.common.base.Charsets @ Use java.nio.charset.StandardCharsets instead

View File

@ -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();

View File

@ -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<SelectResultValue> result = (Result<SelectResultValue>) Iterables.getOnlyElement(seq.toList());

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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.<JSONPathFieldSpec>of()),
ImmutableMap.<String, Boolean>of()
),
Charsets.UTF_8.name()
StandardCharsets.UTF_8.name()
),
Map.class
),

View File

@ -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.<JSONPathFieldSpec>of()),
ImmutableMap.<String, Boolean>of()
),
Charsets.UTF_8.name()
StandardCharsets.UTF_8.name()
),
Map.class
),

View File

@ -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<K, V>
*/
public PopulateResult populate(final ByteSource source, final Map<K, V> map) throws IOException
{
return source.asCharSource(Charsets.UTF_8).readLines(
return source.asCharSource(StandardCharsets.UTF_8).readLines(
new LineProcessor<PopulateResult>()
{
private int lines = 0;

View File

@ -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,

View File

@ -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<WindowedDataSegment> mySegments = ImmutableList.of(
WindowedDataSegment.of(

View File

@ -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()
);
}

View File

@ -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;

View File

@ -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;

View File

@ -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(

View File

@ -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);

View File

@ -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()

View File

@ -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()

View File

@ -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;

View File

@ -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()

View File

@ -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()

View File

@ -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 {

View File

@ -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

View File

@ -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

View File

@ -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");

View File

@ -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) {

View File

@ -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<JsonN
.options(EnumSet.of(Option.SUPPRESS_EXCEPTIONS))
.build();
private final CharsetEncoder enc = Charsets.UTF_8.newEncoder();
private final CharsetEncoder enc = StandardCharsets.UTF_8.newEncoder();
@Override
public Iterable<String> discoverRootFields(final JsonNode obj)

View File

@ -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<String, Object>
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

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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<String> 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<String> lines;
try {
lines = Files.readLines(procMounts, Charsets.UTF_8);
lines = Files.readLines(procMounts, StandardCharsets.UTF_8);
}
catch (IOException e) {
throw new RuntimeException(e);

View File

@ -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());

View File

@ -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());

View File

@ -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

View File

@ -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());

View File

@ -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<StatusResponseHolder> 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<StatusResponseHolder> 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<StatusResponseHolder> 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<StatusResponseHolder> 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<StatusResponseHolder> 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<StatusResponseHolder> 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<StatusResponseHolder> 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;

View File

@ -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);

View File

@ -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);
}

View File

@ -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) {

View File

@ -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<T> implements QueryRunner<T>
? SmileMediaTypes.APPLICATION_JACKSON_SMILE
: MediaType.APPLICATION_JSON
),
new StatusResponseHandler(Charsets.UTF_8),
new StatusResponseHandler(StandardCharsets.UTF_8),
Duration.standardSeconds(1)
).get(1, TimeUnit.SECONDS);

View File

@ -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

View File

@ -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));
}
/**

View File

@ -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
);
}

View File

@ -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);

View File

@ -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<HashCode> hashes = Lists.newArrayList(nodeHash, keyHash);
long combinedHash = Hashing.combineOrdered(hashes).asLong();
if (maxNode == null) {

View File

@ -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(),

View File

@ -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);
}

View File

@ -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 (

View File

@ -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<Row> rows = new ArrayList<>();
while (firehose.hasMore()) {

View File

@ -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);