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