diff --git a/common/src/main/java/io/druid/collections/OrderedMergeIterator.java b/common/src/main/java/io/druid/collections/OrderedMergeIterator.java index 7cfc72adefc..a1214379e84 100644 --- a/common/src/main/java/io/druid/collections/OrderedMergeIterator.java +++ b/common/src/main/java/io/druid/collections/OrderedMergeIterator.java @@ -75,7 +75,7 @@ public class OrderedMergeIterator implements Iterator new Predicate>() { @Override - public boolean apply(@Nullable Iterator input) + public boolean apply(Iterator input) { return input.hasNext(); } @@ -85,7 +85,7 @@ public class OrderedMergeIterator implements Iterator new Function, PeekingIterator>() { @Override - public PeekingIterator apply(@Nullable Iterator input) + public PeekingIterator apply(Iterator input) { return Iterators.peekingIterator(input); } diff --git a/common/src/main/java/io/druid/collections/OrderedMergeSequence.java b/common/src/main/java/io/druid/collections/OrderedMergeSequence.java index 00b1f12d3de..c24404c9a57 100644 --- a/common/src/main/java/io/druid/collections/OrderedMergeSequence.java +++ b/common/src/main/java/io/druid/collections/OrderedMergeSequence.java @@ -83,7 +83,7 @@ public class OrderedMergeSequence implements Sequence new Function, T>() { @Override - public T apply(@Nullable Yielder input) + public T apply(Yielder input) { return input.get(); } diff --git a/common/src/main/java/io/druid/common/utils/JodaUtils.java b/common/src/main/java/io/druid/common/utils/JodaUtils.java index b488f1e5a7d..db6da04e875 100644 --- a/common/src/main/java/io/druid/common/utils/JodaUtils.java +++ b/common/src/main/java/io/druid/common/utils/JodaUtils.java @@ -91,7 +91,7 @@ public class JodaUtils intervals, new Predicate() { @Override - public boolean apply(@Nullable Interval input) + public boolean apply(Interval input) { return input.overlaps(i); } diff --git a/examples/src/main/java/io/druid/examples/web/WebJsonSupplier.java b/examples/src/main/java/io/druid/examples/web/WebJsonSupplier.java index 9372f721145..39d0fae1882 100644 --- a/examples/src/main/java/io/druid/examples/web/WebJsonSupplier.java +++ b/examples/src/main/java/io/druid/examples/web/WebJsonSupplier.java @@ -20,6 +20,7 @@ package io.druid.examples.web; import com.google.api.client.repackaged.com.google.common.base.Throwables; +import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.io.InputSupplier; import com.metamx.emitter.EmittingLogger; @@ -55,6 +56,6 @@ public class WebJsonSupplier implements InputSupplier { URLConnection connection = url.openConnection(); connection.setDoInput(true); - return new BufferedReader(new InputStreamReader(url.openStream())); + return new BufferedReader(new InputStreamReader(url.openStream(), Charsets.UTF_8)); } } diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/Bucket.java b/indexing-hadoop/src/main/java/io/druid/indexer/Bucket.java index ed164a676a9..ddb3455b8de 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/Bucket.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/Bucket.java @@ -26,7 +26,7 @@ import java.nio.ByteBuffer; public class Bucket { - public static int PREAMBLE_BYTES = 16; + public static final int PREAMBLE_BYTES = 16; /** ID for this bucket, unique for this indexer run. Used for grouping and partitioning. */ private final int shardNum; diff --git a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java index 1ff6e5a4482..e6402221e45 100644 --- a/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java +++ b/indexing-hadoop/src/main/java/io/druid/indexer/HadoopDruidIndexerConfig.java @@ -170,7 +170,6 @@ public class HadoopDruidIndexerConfig private volatile HadoopIngestionSpec schema; private volatile PathSpec pathSpec; - private volatile ColumnConfig columnConfig; private volatile Map shardSpecLookups = Maps.newHashMap(); private volatile Map hadoopShardSpecLookup = Maps.newHashMap(); @@ -179,7 +178,6 @@ public class HadoopDruidIndexerConfig final @JsonProperty("schema") HadoopIngestionSpec schema ) { - this.columnConfig = columnConfig; this.schema = schema; this.pathSpec = jsonMapper.convertValue(schema.getIOConfig().getPathSpec(), PathSpec.class); for (Map.Entry> entry : schema.getTuningConfig().getShardSpecs().entrySet()) { @@ -213,11 +211,6 @@ public class HadoopDruidIndexerConfig return schema; } - public ColumnConfig getColumnConfig() - { - return columnConfig; - } - public String getDataSource() { return schema.getDataSchema().getDataSource(); diff --git a/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java b/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java index 1671fb84bd3..a688d2603f2 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/config/TaskConfig.java @@ -28,7 +28,7 @@ import java.util.List; public class TaskConfig { - public static List DEFAULT_DEFAULT_HADOOP_COORDINATES = ImmutableList.of( + public static final List DEFAULT_DEFAULT_HADOOP_COORDINATES = ImmutableList.of( "org.apache.hadoop:hadoop-client:2.3.0" ); diff --git a/indexing-service/src/main/java/io/druid/indexing/common/task/AppendTask.java b/indexing-service/src/main/java/io/druid/indexing/common/task/AppendTask.java index 40807073874..51fb358ac8c 100644 --- a/indexing-service/src/main/java/io/druid/indexing/common/task/AppendTask.java +++ b/indexing-service/src/main/java/io/druid/indexing/common/task/AppendTask.java @@ -97,7 +97,7 @@ public class AppendTask extends MergeTaskBase new Predicate() { @Override - public boolean apply(@Nullable Rowboat input) + public boolean apply(Rowboat input) { return holder.getInterval().contains(input.getTimestamp()); } @@ -115,7 +115,7 @@ public class AppendTask extends MergeTaskBase return "append"; } - private class SegmentToMergeHolder + private static class SegmentToMergeHolder { private final DataSegment segment; private final Interval interval; 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 29749501227..7e66991e188 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 @@ -133,7 +133,7 @@ public abstract class MergeTaskBase extends AbstractFixedIntervalTask new Function() { @Override - public String apply(@Nullable DataSegment input) + public String apply(DataSegment input) { return input.getIdentifier(); } diff --git a/indexing-service/src/main/java/io/druid/indexing/firehose/IngestSegmentFirehoseFactory.java b/indexing-service/src/main/java/io/druid/indexing/firehose/IngestSegmentFirehoseFactory.java index 6987a24e97f..ca496d346ba 100644 --- a/indexing-service/src/main/java/io/druid/indexing/firehose/IngestSegmentFirehoseFactory.java +++ b/indexing-service/src/main/java/io/druid/indexing/firehose/IngestSegmentFirehoseFactory.java @@ -236,7 +236,7 @@ public class IngestSegmentFirehoseFactory implements FirehoseFactory apply(@Nullable StorageAdapter adapter) + public Sequence apply(StorageAdapter adapter) { return Sequences.concat( Sequences.map( @@ -248,7 +248,7 @@ public class IngestSegmentFirehoseFactory implements FirehoseFactory apply(@Nullable final Cursor cursor) + public Sequence apply(final Cursor cursor) { final TimestampColumnSelector timestampColumnSelector = cursor.makeTimestampColumnSelector(); 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 a36e6381678..3d8de3c7001 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 @@ -799,7 +799,7 @@ public class RemoteTaskRunner implements TaskRunner, TaskLogStreamer ZkWorker zkWorker, ZkWorker zkWorker2 ) { - int retVal = -Ints.compare(zkWorker.getCurrCapacityUsed(), zkWorker2.getCurrCapacityUsed()); + int retVal = Ints.compare(zkWorker2.getCurrCapacityUsed(), zkWorker.getCurrCapacityUsed()); if (retVal == 0) { retVal = zkWorker.getWorker().getHost().compareTo(zkWorker2.getWorker().getHost()); } diff --git a/processing/src/main/java/io/druid/granularity/PeriodGranularity.java b/processing/src/main/java/io/druid/granularity/PeriodGranularity.java index aa8b41439a3..2aef4ff4044 100644 --- a/processing/src/main/java/io/druid/granularity/PeriodGranularity.java +++ b/processing/src/main/java/io/druid/granularity/PeriodGranularity.java @@ -21,6 +21,7 @@ package io.druid.granularity; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import org.joda.time.Chronology; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; @@ -325,7 +326,7 @@ public class PeriodGranularity extends BaseQueryGranularity @Override public byte[] cacheKey() { - return (period.toString() + ":" + chronology.getZone().toString()).getBytes(); + return (period.toString() + ":" + chronology.getZone().toString()).getBytes(Charsets.UTF_8); } @Override diff --git a/processing/src/main/java/io/druid/guice/PropertiesModule.java b/processing/src/main/java/io/druid/guice/PropertiesModule.java index bd0868e2414..2314134894b 100644 --- a/processing/src/main/java/io/druid/guice/PropertiesModule.java +++ b/processing/src/main/java/io/druid/guice/PropertiesModule.java @@ -33,6 +33,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.util.Properties; /** @@ -68,8 +69,8 @@ public class PropertiesModule implements Module if (stream != null) { log.info("Loading properties from %s", propertiesFile); - try { - fileProps.load(new InputStreamReader(stream, Charsets.UTF_8)); + try(Reader reader = new InputStreamReader(stream, Charsets.UTF_8)) { + fileProps.load(reader); } catch (IOException e) { throw Throwables.propagate(e); diff --git a/processing/src/main/java/io/druid/query/BaseQuery.java b/processing/src/main/java/io/druid/query/BaseQuery.java index e2052f3ba64..a648f484c78 100644 --- a/processing/src/main/java/io/druid/query/BaseQuery.java +++ b/processing/src/main/java/io/druid/query/BaseQuery.java @@ -36,7 +36,7 @@ import java.util.Map; */ public abstract class BaseQuery implements Query { - public static String QUERYID = "queryId"; + public static final String QUERYID = "queryId"; private final DataSource dataSource; private final Map context; private final QuerySegmentSpec querySegmentSpec; diff --git a/processing/src/main/java/io/druid/query/IntervalChunkingQueryRunner.java b/processing/src/main/java/io/druid/query/IntervalChunkingQueryRunner.java index 0bf4c3928b0..df4c8596217 100644 --- a/processing/src/main/java/io/druid/query/IntervalChunkingQueryRunner.java +++ b/processing/src/main/java/io/druid/query/IntervalChunkingQueryRunner.java @@ -61,7 +61,7 @@ public class IntervalChunkingQueryRunner implements QueryRunner new Function>() { @Override - public Iterable apply(@Nullable Interval input) + public Iterable apply(Interval input) { return splitInterval(input); } diff --git a/processing/src/main/java/io/druid/query/PrioritizedExecutorService.java b/processing/src/main/java/io/druid/query/PrioritizedExecutorService.java index c0dd98b6718..b1a0463d7b0 100644 --- a/processing/src/main/java/io/druid/query/PrioritizedExecutorService.java +++ b/processing/src/main/java/io/druid/query/PrioritizedExecutorService.java @@ -249,7 +249,7 @@ public class PrioritizedExecutorService extends AbstractExecutorService implemen @Override public int compareTo(PrioritizedListenableFutureTask otherTask) { - return -Ints.compare(getPriority(), otherTask.getPriority()); + return Ints.compare(otherTask.getPriority(), getPriority()); } } } diff --git a/processing/src/main/java/io/druid/query/Queries.java b/processing/src/main/java/io/druid/query/Queries.java index 3fd1f802189..7691a8f7eb4 100644 --- a/processing/src/main/java/io/druid/query/Queries.java +++ b/processing/src/main/java/io/druid/query/Queries.java @@ -49,7 +49,7 @@ public class Queries new Function() { @Override - public String apply(@Nullable AggregatorFactory input) + public String apply(AggregatorFactory input) { return input.getName(); } diff --git a/processing/src/main/java/io/druid/query/QueryRunnerHelper.java b/processing/src/main/java/io/druid/query/QueryRunnerHelper.java index 2765cf0e35c..d9c2e147dda 100644 --- a/processing/src/main/java/io/druid/query/QueryRunnerHelper.java +++ b/processing/src/main/java/io/druid/query/QueryRunnerHelper.java @@ -71,7 +71,7 @@ public class QueryRunnerHelper new Function>() { @Override - public Result apply(@Nullable Cursor input) + public Result apply(Cursor input) { log.debug("Running over cursor[%s]", adapter.getInterval(), input.getTime()); return mapFn.apply(input); diff --git a/processing/src/main/java/io/druid/query/aggregation/DoubleSumAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/DoubleSumAggregatorFactory.java index 083a16589dc..713022efade 100644 --- a/processing/src/main/java/io/druid/query/aggregation/DoubleSumAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/DoubleSumAggregatorFactory.java @@ -21,6 +21,7 @@ package io.druid.query.aggregation; 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.primitives.Doubles; import io.druid.segment.ColumnSelectorFactory; @@ -129,7 +130,7 @@ public class DoubleSumAggregatorFactory implements AggregatorFactory @Override public byte[] getCacheKey() { - byte[] fieldNameBytes = fieldName.getBytes(); + byte[] fieldNameBytes = fieldName.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); } diff --git a/processing/src/main/java/io/druid/query/aggregation/HistogramAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/HistogramAggregatorFactory.java index 422d8279a2e..5a99ac9d18c 100644 --- a/processing/src/main/java/io/druid/query/aggregation/HistogramAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/HistogramAggregatorFactory.java @@ -154,7 +154,7 @@ public class HistogramAggregatorFactory implements AggregatorFactory @Override public byte[] getCacheKey() { - byte[] fieldNameBytes = fieldName.getBytes(); + byte[] fieldNameBytes = fieldName.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); } diff --git a/processing/src/main/java/io/druid/query/aggregation/LongSumAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/LongSumAggregatorFactory.java index 963d9458beb..249d37045a0 100644 --- a/processing/src/main/java/io/druid/query/aggregation/LongSumAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/LongSumAggregatorFactory.java @@ -21,6 +21,7 @@ package io.druid.query.aggregation; 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.primitives.Longs; import io.druid.segment.ColumnSelectorFactory; @@ -125,7 +126,7 @@ public class LongSumAggregatorFactory implements AggregatorFactory @Override public byte[] getCacheKey() { - byte[] fieldNameBytes = fieldName.getBytes(); + byte[] fieldNameBytes = fieldName.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); } diff --git a/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java index 56e6de5f56e..23c8b066c25 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/MaxAggregatorFactory.java @@ -21,6 +21,7 @@ package io.druid.query.aggregation; 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.primitives.Doubles; import io.druid.segment.ColumnSelectorFactory; @@ -126,7 +127,7 @@ public class MaxAggregatorFactory implements AggregatorFactory @Override public byte[] getCacheKey() { - byte[] fieldNameBytes = fieldName.getBytes(); + byte[] fieldNameBytes = fieldName.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); } diff --git a/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java b/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java index e7256d0ccb9..859ed2b23cd 100644 --- a/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java +++ b/processing/src/main/java/io/druid/query/aggregation/MinAggregatorFactory.java @@ -21,6 +21,7 @@ package io.druid.query.aggregation; 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.primitives.Doubles; import io.druid.segment.ColumnSelectorFactory; @@ -126,7 +127,7 @@ public class MinAggregatorFactory implements AggregatorFactory @Override public byte[] getCacheKey() { - byte[] fieldNameBytes = fieldName.getBytes(); + byte[] fieldNameBytes = fieldName.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + fieldNameBytes.length).put(CACHE_TYPE_ID).put(fieldNameBytes).array(); } diff --git a/processing/src/main/java/io/druid/query/dimension/DefaultDimensionSpec.java b/processing/src/main/java/io/druid/query/dimension/DefaultDimensionSpec.java index ee5ee674293..cb44fe59c6c 100644 --- a/processing/src/main/java/io/druid/query/dimension/DefaultDimensionSpec.java +++ b/processing/src/main/java/io/druid/query/dimension/DefaultDimensionSpec.java @@ -21,6 +21,7 @@ package io.druid.query.dimension; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import io.druid.query.extraction.DimExtractionFn; import java.nio.ByteBuffer; @@ -68,7 +69,7 @@ public class DefaultDimensionSpec implements DimensionSpec @Override public byte[] getCacheKey() { - byte[] dimensionBytes = dimension.getBytes(); + byte[] dimensionBytes = dimension.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + dimensionBytes.length) .put(CACHE_TYPE_ID) diff --git a/processing/src/main/java/io/druid/query/dimension/ExtractionDimensionSpec.java b/processing/src/main/java/io/druid/query/dimension/ExtractionDimensionSpec.java index 878de5bbad5..c692f1399fb 100644 --- a/processing/src/main/java/io/druid/query/dimension/ExtractionDimensionSpec.java +++ b/processing/src/main/java/io/druid/query/dimension/ExtractionDimensionSpec.java @@ -21,6 +21,7 @@ package io.druid.query.dimension; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import io.druid.query.extraction.DimExtractionFn; import java.nio.ByteBuffer; @@ -73,7 +74,7 @@ public class ExtractionDimensionSpec implements DimensionSpec @Override public byte[] getCacheKey() { - byte[] dimensionBytes = dimension.getBytes(); + byte[] dimensionBytes = dimension.getBytes(Charsets.UTF_8); byte[] dimExtractionFnBytes = dimExtractionFn.getCacheKey(); return ByteBuffer.allocate(1 + dimensionBytes.length + dimExtractionFnBytes.length) diff --git a/processing/src/main/java/io/druid/query/extraction/JavascriptDimExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/JavascriptDimExtractionFn.java index 3935e07c293..e8099e643a4 100644 --- a/processing/src/main/java/io/druid/query/extraction/JavascriptDimExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/JavascriptDimExtractionFn.java @@ -21,6 +21,7 @@ package io.druid.query.extraction; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.google.common.base.Function; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; @@ -80,7 +81,7 @@ public class JavascriptDimExtractionFn implements DimExtractionFn @Override public byte[] getCacheKey() { - byte[] bytes = function.getBytes(); + byte[] bytes = function.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + bytes.length) .put(CACHE_TYPE_ID) .put(bytes) diff --git a/processing/src/main/java/io/druid/query/extraction/PartialDimExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/PartialDimExtractionFn.java index 8b6a3b58017..323c7989387 100644 --- a/processing/src/main/java/io/druid/query/extraction/PartialDimExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/PartialDimExtractionFn.java @@ -21,6 +21,7 @@ package io.druid.query.extraction; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import java.nio.ByteBuffer; import java.util.regex.Matcher; @@ -47,7 +48,7 @@ public class PartialDimExtractionFn implements DimExtractionFn @Override public byte[] getCacheKey() { - byte[] exprBytes = expr.getBytes(); + byte[] exprBytes = expr.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + exprBytes.length) .put(CACHE_TYPE_ID) .put(exprBytes) diff --git a/processing/src/main/java/io/druid/query/extraction/RegexDimExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/RegexDimExtractionFn.java index 50a418afed3..636507c1273 100644 --- a/processing/src/main/java/io/druid/query/extraction/RegexDimExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/RegexDimExtractionFn.java @@ -21,6 +21,7 @@ package io.druid.query.extraction; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import java.nio.ByteBuffer; import java.util.regex.Matcher; @@ -47,7 +48,7 @@ public class RegexDimExtractionFn implements DimExtractionFn @Override public byte[] getCacheKey() { - byte[] exprBytes = expr.getBytes(); + byte[] exprBytes = expr.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + exprBytes.length) .put(CACHE_TYPE_ID) .put(exprBytes) diff --git a/processing/src/main/java/io/druid/query/extraction/TimeDimExtractionFn.java b/processing/src/main/java/io/druid/query/extraction/TimeDimExtractionFn.java index 215f8c32aee..25c7bde0cfa 100644 --- a/processing/src/main/java/io/druid/query/extraction/TimeDimExtractionFn.java +++ b/processing/src/main/java/io/druid/query/extraction/TimeDimExtractionFn.java @@ -21,6 +21,7 @@ package io.druid.query.extraction; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.ibm.icu.text.SimpleDateFormat; import java.nio.ByteBuffer; @@ -55,7 +56,7 @@ public class TimeDimExtractionFn implements DimExtractionFn @Override public byte[] getCacheKey() { - byte[] timeFormatBytes = timeFormat.getBytes(); + byte[] timeFormatBytes = timeFormat.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + timeFormatBytes.length) .put(CACHE_TYPE_ID) .put(timeFormatBytes) diff --git a/processing/src/main/java/io/druid/query/filter/ExtractionDimFilter.java b/processing/src/main/java/io/druid/query/filter/ExtractionDimFilter.java index 8ce26f71f99..65fa0e4494c 100644 --- a/processing/src/main/java/io/druid/query/filter/ExtractionDimFilter.java +++ b/processing/src/main/java/io/druid/query/filter/ExtractionDimFilter.java @@ -21,6 +21,7 @@ package io.druid.query.filter; 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 io.druid.query.extraction.DimExtractionFn; @@ -71,8 +72,8 @@ public class ExtractionDimFilter implements DimFilter @Override public byte[] getCacheKey() { - byte[] dimensionBytes = dimension.getBytes(); - byte[] valueBytes = value.getBytes(); + byte[] dimensionBytes = dimension.getBytes(Charsets.UTF_8); + byte[] valueBytes = value.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + dimensionBytes.length + valueBytes.length) .put(DimFilterCacheHelper.EXTRACTION_CACHE_ID) diff --git a/processing/src/main/java/io/druid/query/filter/SelectorDimFilter.java b/processing/src/main/java/io/druid/query/filter/SelectorDimFilter.java index b8d1580a169..414b475d1fe 100644 --- a/processing/src/main/java/io/druid/query/filter/SelectorDimFilter.java +++ b/processing/src/main/java/io/druid/query/filter/SelectorDimFilter.java @@ -21,6 +21,7 @@ package io.druid.query.filter; 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 java.nio.ByteBuffer; @@ -47,8 +48,8 @@ public class SelectorDimFilter implements DimFilter @Override public byte[] getCacheKey() { - byte[] dimensionBytes = dimension.getBytes(); - byte[] valueBytes = (value == null) ? new byte[]{} : value.getBytes(); + byte[] dimensionBytes = dimension.getBytes(Charsets.UTF_8); + byte[] valueBytes = (value == null) ? new byte[]{} : value.getBytes(Charsets.UTF_8); return ByteBuffer.allocate(1 + dimensionBytes.length + valueBytes.length) .put(DimFilterCacheHelper.SELECTOR_CACHE_ID) diff --git a/processing/src/main/java/io/druid/query/filter/SpatialDimFilter.java b/processing/src/main/java/io/druid/query/filter/SpatialDimFilter.java index 2abcc9282b3..7148ebf55e7 100644 --- a/processing/src/main/java/io/druid/query/filter/SpatialDimFilter.java +++ b/processing/src/main/java/io/druid/query/filter/SpatialDimFilter.java @@ -20,6 +20,7 @@ package io.druid.query.filter; 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.metamx.collections.spatial.search.Bound; @@ -48,7 +49,7 @@ public class SpatialDimFilter implements DimFilter @Override public byte[] getCacheKey() { - byte[] dimBytes = dimension.getBytes(); + byte[] dimBytes = dimension.getBytes(Charsets.UTF_8); byte[] boundBytes = bound.getCacheKey(); return ByteBuffer.allocate(1 + dimBytes.length + boundBytes.length) diff --git a/processing/src/main/java/io/druid/query/groupby/GroupByQueryEngine.java b/processing/src/main/java/io/druid/query/groupby/GroupByQueryEngine.java index a3cc06c0b9a..341090f3176 100644 --- a/processing/src/main/java/io/druid/query/groupby/GroupByQueryEngine.java +++ b/processing/src/main/java/io/druid/query/groupby/GroupByQueryEngine.java @@ -236,7 +236,7 @@ public class GroupByQueryEngine } } - private class PositionMaintainer + private static class PositionMaintainer { private final int[] increments; private final int increment; @@ -284,7 +284,7 @@ public class GroupByQueryEngine } } - private class RowIterator implements CloseableIterator + private static class RowIterator implements CloseableIterator { private final GroupByQuery query; private final Cursor cursor; diff --git a/processing/src/main/java/io/druid/query/groupby/having/EqualToHavingSpec.java b/processing/src/main/java/io/druid/query/groupby/having/EqualToHavingSpec.java index bc26524e60b..b0389edfca7 100644 --- a/processing/src/main/java/io/druid/query/groupby/having/EqualToHavingSpec.java +++ b/processing/src/main/java/io/druid/query/groupby/having/EqualToHavingSpec.java @@ -21,6 +21,7 @@ package io.druid.query.groupby.having; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.google.common.primitives.Bytes; import io.druid.data.input.Row; @@ -71,7 +72,7 @@ public class EqualToHavingSpec implements HavingSpec @Override public byte[] getCacheKey() { - final byte[] aggBytes = aggregationName.getBytes(); + final byte[] aggBytes = aggregationName.getBytes(Charsets.UTF_8); final byte[] valBytes = Bytes.toArray(Arrays.asList(value)); return ByteBuffer.allocate(1 + aggBytes.length + valBytes.length) .put(CACHE_KEY) diff --git a/processing/src/main/java/io/druid/query/groupby/having/GreaterThanHavingSpec.java b/processing/src/main/java/io/druid/query/groupby/having/GreaterThanHavingSpec.java index 68a8113bf55..19349a2098b 100644 --- a/processing/src/main/java/io/druid/query/groupby/having/GreaterThanHavingSpec.java +++ b/processing/src/main/java/io/druid/query/groupby/having/GreaterThanHavingSpec.java @@ -21,6 +21,7 @@ package io.druid.query.groupby.having; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.google.common.primitives.Bytes; import io.druid.data.input.Row; @@ -71,7 +72,7 @@ public class GreaterThanHavingSpec implements HavingSpec @Override public byte[] getCacheKey() { - final byte[] aggBytes = aggregationName.getBytes(); + final byte[] aggBytes = aggregationName.getBytes(Charsets.UTF_8); final byte[] valBytes = Bytes.toArray(Arrays.asList(value)); return ByteBuffer.allocate(1 + aggBytes.length + valBytes.length) .put(CACHE_KEY) diff --git a/processing/src/main/java/io/druid/query/groupby/having/LessThanHavingSpec.java b/processing/src/main/java/io/druid/query/groupby/having/LessThanHavingSpec.java index 4ee782734f2..284ddc7042c 100644 --- a/processing/src/main/java/io/druid/query/groupby/having/LessThanHavingSpec.java +++ b/processing/src/main/java/io/druid/query/groupby/having/LessThanHavingSpec.java @@ -20,6 +20,7 @@ package io.druid.query.groupby.having; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.google.common.primitives.Bytes; import io.druid.data.input.Row; @@ -69,7 +70,7 @@ public class LessThanHavingSpec implements HavingSpec @Override public byte[] getCacheKey() { - final byte[] aggBytes = aggregationName.getBytes(); + final byte[] aggBytes = aggregationName.getBytes(Charsets.UTF_8); final byte[] valBytes = Bytes.toArray(Arrays.asList(value)); return ByteBuffer.allocate(1 + aggBytes.length + valBytes.length) .put(CACHE_KEY) diff --git a/processing/src/main/java/io/druid/query/groupby/orderby/OrderByColumnSpec.java b/processing/src/main/java/io/druid/query/groupby/orderby/OrderByColumnSpec.java index efb91a9c3c0..2c471d62507 100644 --- a/processing/src/main/java/io/druid/query/groupby/orderby/OrderByColumnSpec.java +++ b/processing/src/main/java/io/druid/query/groupby/orderby/OrderByColumnSpec.java @@ -21,6 +21,7 @@ package io.druid.query.groupby.orderby; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; @@ -182,8 +183,8 @@ public class OrderByColumnSpec public byte[] getCacheKey() { - final byte[] dimensionBytes = dimension.getBytes(); - final byte[] directionBytes = direction.name().getBytes(); + final byte[] dimensionBytes = dimension.getBytes(Charsets.UTF_8); + final byte[] directionBytes = direction.name().getBytes(Charsets.UTF_8); return ByteBuffer.allocate(dimensionBytes.length + directionBytes.length) .put(dimensionBytes) diff --git a/processing/src/main/java/io/druid/query/search/SearchQueryQueryToolChest.java b/processing/src/main/java/io/druid/query/search/SearchQueryQueryToolChest.java index 558d7ee3f13..74fc8d55f17 100644 --- a/processing/src/main/java/io/druid/query/search/SearchQueryQueryToolChest.java +++ b/processing/src/main/java/io/druid/query/search/SearchQueryQueryToolChest.java @@ -20,6 +20,7 @@ package io.druid.query.search; import com.fasterxml.jackson.core.type.TypeReference; +import com.google.common.base.Charsets; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.base.Joiner; @@ -172,7 +173,7 @@ public class SearchQueryQueryToolChest extends QueryToolChest entry : pagingIdentifiers.entrySet()) { - pagingKeys[index] = entry.getKey().getBytes(); + pagingKeys[index] = entry.getKey().getBytes(Charsets.UTF_8); pagingValues[index] = ByteBuffer.allocate(Ints.BYTES).putInt(entry.getValue()).array(); pagingKeysSize += pagingKeys[index].length; pagingValuesSize += Ints.BYTES; diff --git a/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java b/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java index 345aeff1d5b..6f08110f781 100644 --- a/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java +++ b/processing/src/main/java/io/druid/query/select/SelectQueryQueryToolChest.java @@ -21,6 +21,7 @@ package io.druid.query.select; 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.Functions; import com.google.common.base.Joiner; @@ -173,7 +174,7 @@ public class SelectQueryQueryToolChest extends QueryToolChest() { @Override - public String apply(@Nullable DruidDataSource dataSource) + public String apply(DruidDataSource dataSource) { return dataSource.getName(); } @@ -126,7 +126,7 @@ public class DBResource new Function() { @Override - public Object apply(@Nullable DataSegment segment) + public Object apply(DataSegment segment) { return segment.getIdentifier(); } diff --git a/server/src/main/java/io/druid/server/http/DatasourcesResource.java b/server/src/main/java/io/druid/server/http/DatasourcesResource.java index f99586c1056..4203c372ef5 100644 --- a/server/src/main/java/io/druid/server/http/DatasourcesResource.java +++ b/server/src/main/java/io/druid/server/http/DatasourcesResource.java @@ -261,7 +261,7 @@ public class DatasourcesResource final DruidDataSource dataSource = getDataSource(dataSourceName.toLowerCase()); final Interval theInterval = new Interval(interval.replace("_", "/")); - if (dataSource == null || interval == null) { + if (dataSource == null) { return Response.noContent().build(); } diff --git a/server/src/main/java/io/druid/server/http/ServersResource.java b/server/src/main/java/io/druid/server/http/ServersResource.java index ed43c340e8d..3a7b325d202 100644 --- a/server/src/main/java/io/druid/server/http/ServersResource.java +++ b/server/src/main/java/io/druid/server/http/ServersResource.java @@ -158,7 +158,7 @@ public class ServersResource new Function() { @Override - public String apply(@Nullable DataSegment segment) + public String apply(DataSegment segment) { return segment.getIdentifier(); } diff --git a/server/src/main/java/io/druid/server/log/EmittingRequestLogger.java b/server/src/main/java/io/druid/server/log/EmittingRequestLogger.java index 798978d6d2f..21a8bde1599 100644 --- a/server/src/main/java/io/druid/server/log/EmittingRequestLogger.java +++ b/server/src/main/java/io/druid/server/log/EmittingRequestLogger.java @@ -125,7 +125,7 @@ public class EmittingRequestLogger implements RequestLogger } } - private class RequestLogEventBuilder implements ServiceEventBuilder + private static class RequestLogEventBuilder implements ServiceEventBuilder { private final String feed; private final RequestLogLine requestLogLine; 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 ba69f58fc8e..e993f357648 100644 --- a/server/src/main/java/io/druid/server/log/FileRequestLogger.java +++ b/server/src/main/java/io/druid/server/log/FileRequestLogger.java @@ -20,6 +20,7 @@ package io.druid.server.log; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.metamx.common.concurrent.ScheduledExecutors; import com.metamx.common.guava.CloseQuietly; @@ -31,8 +32,9 @@ import org.joda.time.Duration; import org.joda.time.MutableDateTime; import java.io.File; -import java.io.FileWriter; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.OutputStreamWriter; import java.util.concurrent.Callable; import java.util.concurrent.ScheduledExecutorService; @@ -47,7 +49,7 @@ public class FileRequestLogger implements RequestLogger private final Object lock = new Object(); private volatile DateTime currentDay; - private volatile FileWriter fileWriter; + private volatile OutputStreamWriter fileWriter; public FileRequestLogger(ObjectMapper objectMapper, ScheduledExecutorService exec, File baseDir) { @@ -66,7 +68,10 @@ public class FileRequestLogger implements RequestLogger mutableDateTime.setMillisOfDay(0); currentDay = mutableDateTime.toDateTime(); - fileWriter = new FileWriter(new File(baseDir, currentDay.toString("yyyy-MM-dd'.log'")), true); + fileWriter = new OutputStreamWriter( + new FileOutputStream(new File(baseDir, currentDay.toString("yyyy-MM-dd'.log'")), true), + Charsets.UTF_8 + ); long nextDay = currentDay.plusDays(1).getMillis(); Duration delay = new Duration(nextDay - new DateTime().getMillis()); @@ -84,7 +89,10 @@ public class FileRequestLogger implements RequestLogger try { synchronized (lock) { CloseQuietly.close(fileWriter); - fileWriter = new FileWriter(new File(baseDir, currentDay.toString()), true); + fileWriter = new OutputStreamWriter( + new FileOutputStream(new File(baseDir, currentDay.toString()), true), + Charsets.UTF_8 + ); } } catch (Exception e) { diff --git a/server/src/main/java/io/druid/server/sql/SQLRunner.java b/server/src/main/java/io/druid/server/sql/SQLRunner.java index 68a00bccc30..ca16426721f 100644 --- a/server/src/main/java/io/druid/server/sql/SQLRunner.java +++ b/server/src/main/java/io/druid/server/sql/SQLRunner.java @@ -145,7 +145,7 @@ public class SQLRunner final URLConnection urlConnection = url.openConnection(); urlConnection.addRequestProperty("content-type", "application/json"); urlConnection.getOutputStream().write(queryStr.getBytes(Charsets.UTF_8)); - BufferedReader stdInput = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); + BufferedReader stdInput = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8)); Object res = objectMapper.readValue(stdInput, typeRef);