You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2021/09/29 13:37:02 UTC
[phoenix] branch master updated: PHOENIX-6557 Fix code problems
flagged by SpotBugs as High priority
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new dd3d853 PHOENIX-6557 Fix code problems flagged by SpotBugs as High priority
dd3d853 is described below
commit dd3d85366a0be46a1b3221600835a74bf27b343c
Author: Istvan Toth <st...@apache.org>
AuthorDate: Tue Sep 21 15:16:54 2021 +0200
PHOENIX-6557 Fix code problems flagged by SpotBugs as High priority
---
.../phoenix/cache/aggcache/SpillManager.java | 2 +-
.../apache/phoenix/compile/ExpressionCompiler.java | 3 ++-
.../org/apache/phoenix/compile/JoinCompiler.java | 1 -
.../phoenix/compile/OrderPreservingTracker.java | 3 ++-
.../phoenix/compile/ServerBuildIndexCompiler.java | 2 +-
.../apache/phoenix/compile/SubselectRewriter.java | 3 ++-
.../phoenix/compile/TupleProjectionCompiler.java | 2 +-
.../phoenix/coprocessor/MetaDataEndpointImpl.java | 22 +++++++++++-----
.../coprocessor/PhoenixAccessController.java | 2 +-
.../org/apache/phoenix/execute/BaseQueryPlan.java | 4 ++-
.../org/apache/phoenix/execute/HashJoinPlan.java | 4 ++-
.../apache/phoenix/expression/LikeExpression.java | 10 +++++++-
.../expression/ProjectedColumnExpression.java | 2 +-
.../aggregator/BaseDecimalStddevAggregator.java | 3 +--
.../aggregator/FirstLastValueServerAggregator.java | 5 ++--
.../expression/function/ArrayFillFunction.java | 2 +-
.../phoenix/expression/util/regex/JONIPattern.java | 2 +-
.../TrackingParallelWriterIndexCommitter.java | 2 +-
.../apache/phoenix/index/PhoenixIndexCodec.java | 2 +-
.../iterate/NonAggregateRegionScannerFactory.java | 2 +-
.../org/apache/phoenix/jdbc/PhoenixConnection.java | 7 ++---
.../phoenix/jdbc/PhoenixPreparedStatement.java | 5 ----
.../phoenix/mapreduce/CsvBulkImportUtil.java | 8 +++---
.../phoenix/mapreduce/MultiHfileOutputFormat.java | 7 ++++-
.../apache/phoenix/mapreduce/OrphanViewTool.java | 16 +++++++++---
.../phoenix/mapreduce/PhoenixInputFormat.java | 2 +-
.../PhoenixServerBuildIndexInputFormat.java | 10 ++++----
.../bulkload/TargetTableRefFunctions.java | 10 ++++----
.../mapreduce/index/IndexScrutinyMapper.java | 2 +-
.../mapreduce/index/IndexScrutinyTableOutput.java | 2 +-
.../phoenix/mapreduce/index/IndexScrutinyTool.java | 1 -
.../apache/phoenix/mapreduce/index/IndexTool.java | 2 +-
.../phoenix/mapreduce/index/IndexUpgradeTool.java | 4 ++-
.../index/IndexVerificationOutputRepository.java | 2 +-
.../index/IndexVerificationResultRepository.java | 12 ++++-----
.../index/PhoenixIndexImportDirectMapper.java | 6 +++--
.../index/PhoenixIndexImportDirectReducer.java | 2 +-
.../index/PhoenixIndexPartialBuildMapper.java | 6 +++--
.../index/PhoenixServerBuildIndexMapper.java | 7 +++--
.../index/automation/PhoenixMRJobSubmitter.java | 1 -
.../util/DefaultMultiViewSplitStrategy.java | 2 +-
.../mapreduce/util/PhoenixConfigurationUtil.java | 4 +--
.../phoenix/monitoring/CombinableMetric.java | 6 ++---
.../phoenix/monitoring/CombinableMetricImpl.java | 2 +-
.../phoenix/monitoring/TableMetricsManager.java | 4 +++
.../java/org/apache/phoenix/optimize/Cost.java | 4 +--
.../apache/phoenix/parse/ChangePermsStatement.java | 3 ++-
.../java/org/apache/phoenix/parse/PFunction.java | 6 +++--
.../phoenix/query/ConnectionQueryServicesImpl.java | 12 +++++----
.../query/ConnectionlessQueryServicesImpl.java | 4 ---
.../phoenix/query/ITGuidePostsCacheFactory.java | 2 +-
.../org/apache/phoenix/query/QueryConstants.java | 5 ++--
.../apache/phoenix/query/QueryServicesOptions.java | 2 +-
.../org/apache/phoenix/schema/MetaDataClient.java | 20 ++++++++-------
.../org/apache/phoenix/schema/PMetaDataImpl.java | 2 +-
.../java/org/apache/phoenix/schema/PTableImpl.java | 2 +-
.../apache/phoenix/schema/SequenceAllocation.java | 4 +++
.../phoenix/schema/stats/GuidePostsInfo.java | 5 ++++
.../phoenix/schema/stats/UpdateStatisticsTool.java | 5 +++-
.../java/org/apache/phoenix/schema/task/Task.java | 4 +++
.../schema/tool/SchemaSynthesisProcessor.java | 7 +++--
.../org/apache/phoenix/schema/tool/SchemaTool.java | 4 +++
.../phoenix/schema/types/PArrayDataType.java | 4 +++
.../schema/types/PArrayDataTypeEncoder.java | 2 +-
.../org/apache/phoenix/schema/types/PDataType.java | 8 +-----
.../org/apache/phoenix/schema/types/PDecimal.java | 5 ++--
.../apache/phoenix/schema/types/PhoenixArray.java | 2 +-
.../org/apache/phoenix/trace/TracingUtils.java | 8 ++++--
.../org/apache/phoenix/trace/util/NullSpan.java | 2 +-
.../java/org/apache/phoenix/util/ColumnInfo.java | 5 ++--
.../java/org/apache/phoenix/util/IndexUtil.java | 3 ++-
.../java/org/apache/phoenix/util/MetaDataUtil.java | 5 ++--
.../org/apache/phoenix/util/PhoenixMRJobUtil.java | 3 ++-
.../org/apache/phoenix/util/PhoenixRuntime.java | 16 +++++++++---
.../java/org/apache/phoenix/util/QueryUtil.java | 2 +-
.../java/org/apache/phoenix/util/SchemaUtil.java | 9 ++++---
.../java/org/apache/phoenix/util/StringUtil.java | 12 +++++++--
.../java/org/apache/phoenix/util/UpgradeUtil.java | 23 +++++++++++------
pom.xml | 4 +++
src/main/config/spotbugs/spotbugs-exclude.xml | 30 ++++++++++++++++++++++
80 files changed, 289 insertions(+), 153 deletions(-)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
index e5d3717..a4bca66 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/cache/aggcache/SpillManager.java
@@ -249,7 +249,7 @@ public class SpillManager implements Closeable {
// Determines the partition, i.e. spillFile the tuple should get spilled to.
private int getPartition(ImmutableBytesWritable key) {
// Simple implementation hash mod numFiles
- return Math.abs(key.hashCode()) % numSpillFiles;
+ return (int)(Math.abs((long)key.hashCode()) % numSpillFiles);
}
/**
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
index 85c5553..c52316b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ExpressionCompiler.java
@@ -19,6 +19,7 @@ package org.apache.phoenix.compile;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ArrayList;
@@ -520,7 +521,7 @@ public class ExpressionCompiler extends UnsupportedAllParseNodeVisitor<Expressio
byte[] wildcardString = new byte[pattern.length()];
byte[] wildcard = {StringUtil.MULTI_CHAR_LIKE};
StringUtil.fill(wildcardString, 0, pattern.length(), wildcard, 0, 1, false);
- if (pattern.equals(new String (wildcardString))) {
+ if (pattern.equals(new String(wildcardString, StandardCharsets.UTF_8))) {
List<Expression> compareChildren = Arrays.asList(lhs, NOT_NULL_STRING);
return new ComparisonExpression(compareChildren, node.isNegate() ? CompareOp.LESS : CompareOp.GREATER_OR_EQUAL);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
index d2a3175..bf38387 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/JoinCompiler.java
@@ -1489,7 +1489,6 @@ public class JoinCompiler {
}
private boolean isWildCardSelectForTable(List<AliasedNode> select, TableRef tableRef, ColumnResolver resolver) throws SQLException {
- ColumnRefParseNodeVisitor visitor = new ColumnRefParseNodeVisitor(resolver, phoenixStatement.getConnection());
for (AliasedNode aliasedNode : select) {
ParseNode node = aliasedNode.getNode();
if (node instanceof TableWildcardParseNode) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderPreservingTracker.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderPreservingTracker.java
index 80a0f42..2701a48 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderPreservingTracker.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/OrderPreservingTracker.java
@@ -310,7 +310,8 @@ public class OrderPreservingTracker {
for (int i = 0; i < orderPreservingTrackInfos.size(); i++) {
Info entry = orderPreservingTrackInfos.get(i);
int pos = entry.pkPosition;
- isOrderPreserving &= entry.orderPreserving != OrderPreserving.NO &&
+ isOrderPreserving = isOrderPreserving &&
+ entry.orderPreserving != OrderPreserving.NO &&
prevOrderPreserving == OrderPreserving.YES &&
(pos == prevPos ||
pos - prevSlotSpan == prevPos ||
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ServerBuildIndexCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ServerBuildIndexCompiler.java
index 007bb23..27e3585 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ServerBuildIndexCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ServerBuildIndexCompiler.java
@@ -132,7 +132,7 @@ public class ServerBuildIndexCompiler {
.get(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS);
if (rebuildPageRowSize != null) {
scan.setAttribute(BaseScannerRegionObserver.INDEX_REBUILD_PAGE_ROWS,
- Bytes.toBytes(Long.valueOf(rebuildPageRowSize)));
+ Bytes.toBytes(Long.parseLong(rebuildPageRowSize)));
}
BaseQueryPlan.serializeViewConstantsIntoScan(scan, dataTable);
addEmptyColumnToScan(scan, indexMaintainer.getDataEmptyKeyValueCF(), indexMaintainer.getEmptyKeyValueQualifier());
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java
index a7d6dab..93dadae 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/SubselectRewriter.java
@@ -510,7 +510,8 @@ public class SubselectRewriter extends ParseNodeRewriter {
ParseNode node = aliasedNode.getNode();
if (node instanceof WildcardParseNode
|| (node instanceof TableWildcardParseNode
- && ((TableWildcardParseNode) node).getTableName().equals(tableAlias))) {
+ && ((TableWildcardParseNode) node).getTableName().toString().
+ equals(tableAlias))) {
for (AliasedNode aNode : subselect.getSelect()) {
String alias = aNode.getAlias();
String aliasRewrite = alias == null ? null : SchemaUtil.getColumnName(tableAlias, alias);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
index 716123c..9a0b5b7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/TupleProjectionCompiler.java
@@ -150,7 +150,7 @@ public class TupleProjectionCompiler {
projectedColumns.add(column);
// Wildcard or FamilyWildcard will be handled by ProjectionCompiler.
- if (!isWildcard && !families.contains(sourceColumn.getFamilyName())) {
+ if (!isWildcard && !families.contains(sourceColumn.getFamilyName().toString())) {
EncodedColumnsUtil.setColumns(column, table, context.getScan());
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index b4319ad..c69d8cc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -89,6 +89,7 @@ import static org.apache.phoenix.util.ViewUtil.findAllDescendantViews;
import static org.apache.phoenix.util.ViewUtil.getSystemTableForChildLinks;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.security.PrivilegedExceptionAction;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
@@ -1276,8 +1277,8 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
// famName contains the logical name of the parent table. We need to get the actual physical name of the table
PTable parentTable = null;
if (indexType != IndexType.LOCAL) {
- parentTable = getTable(null, SchemaUtil.getSchemaNameFromFullName(famName.getBytes()).getBytes(),
- SchemaUtil.getTableNameFromFullName(famName.getBytes()).getBytes(), clientTimeStamp, clientVersion);
+ parentTable = getTable(null, SchemaUtil.getSchemaNameFromFullName(famName.getBytes()).getBytes(StandardCharsets.UTF_8),
+ SchemaUtil.getTableNameFromFullName(famName.getBytes()).getBytes(StandardCharsets.UTF_8), clientTimeStamp, clientVersion);
if (parentTable == null) {
// parentTable is not in the cache. Since famName is only logical name, we need to find the physical table.
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)) {
@@ -1290,8 +1291,13 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
if (parentTable == null) {
if (indexType == IndexType.LOCAL) {
- PName tablePhysicalName = getPhysicalTableName(env.getRegion(),null, SchemaUtil.getSchemaNameFromFullName(famName.getBytes()).getBytes(),
- SchemaUtil.getTableNameFromFullName(famName.getBytes()).getBytes(), clientTimeStamp);
+ PName tablePhysicalName = getPhysicalTableName(
+ env.getRegion(),null,
+ SchemaUtil.getSchemaNameFromFullName(
+ famName.getBytes()).getBytes(StandardCharsets.UTF_8),
+ SchemaUtil.getTableNameFromFullName(
+ famName.getBytes()).getBytes(StandardCharsets.UTF_8),
+ clientTimeStamp);
if (tablePhysicalName == null) {
physicalTables.add(famName);
} else {
@@ -1821,8 +1827,10 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
byte[] colBytes = rowKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX];
byte[] famBytes = rowKeyMetaData[PhoenixDatabaseMetaData.FAMILY_NAME_INDEX];
if ((colBytes == null || colBytes.length == 0) && (famBytes != null && famBytes.length > 0)) {
- byte[] sName = SchemaUtil.getSchemaNameFromFullName(famBytes).getBytes();
- byte[] tName = SchemaUtil.getTableNameFromFullName(famBytes).getBytes();
+ byte[] sName =
+ SchemaUtil.getSchemaNameFromFullName(famBytes).getBytes(StandardCharsets.UTF_8);
+ byte[] tName =
+ SchemaUtil.getTableNameFromFullName(famBytes).getBytes(StandardCharsets.UTF_8);
schemaTableNames[0] = tenantId;
schemaTableNames[1] = sName;
schemaTableNames[2] = tName;
@@ -1980,7 +1988,7 @@ TABLE_FAMILY_BYTES, TABLE_SEQ_NUM_BYTES);
// The view index physical table name is constructed from logical name of base table.
// For example, _IDX_SC.TBL1 is the view index name and SC.TBL1 is the logical name of the base table.
String namepaceMappedParentLogicalName = MetaDataUtil.getNamespaceMappedName(parentTable.getBaseTableLogicalName(), isNamespaceMapped);
- cPhysicalName = MetaDataUtil.getViewIndexPhysicalName(namepaceMappedParentLogicalName.getBytes());
+ cPhysicalName = MetaDataUtil.getViewIndexPhysicalName(namepaceMappedParentLogicalName.getBytes(StandardCharsets.UTF_8));
cParentPhysicalName = parentTable.getPhysicalName().getBytes();
} else {
cParentPhysicalName = SchemaUtil
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
index e15ac43..c6f49a5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/PhoenixAccessController.java
@@ -746,7 +746,7 @@ public class PhoenixAccessController extends BaseMetaDataEndpointObserver {
StringBuilder sb = new StringBuilder();
sb.append(" (user=").append(user != null ? user : "UNKNOWN").append(", ");
sb.append("scope=").append(table == null ? "GLOBAL" : table.getNameWithNamespaceInclAsString()).append(", ");
- sb.append(actions.size() > 1 ? "actions=" : "action=").append(actions != null ? actions.toString() : "")
+ sb.append(actions.size() > 1 ? "actions=" : "action=").append(actions.toString())
.append(")");
return sb.toString();
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
index 7ec5da8..05fb924 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/BaseQueryPlan.java
@@ -20,6 +20,7 @@ package org.apache.phoenix.execute;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.ParameterMetaData;
import java.sql.SQLException;
import java.util.Collections;
@@ -324,7 +325,8 @@ public abstract class BaseQueryPlan implements QueryPlan {
ScanUtil.setTenantId(scan, tenantIdBytes);
String customAnnotations = LogUtil.customAnnotationsToString(connection);
- ScanUtil.setCustomAnnotations(scan, customAnnotations == null ? null : customAnnotations.getBytes());
+ ScanUtil.setCustomAnnotations(scan, customAnnotations == null ? null
+ : customAnnotations.getBytes(StandardCharsets.UTF_8));
// Set local index related scan attributes.
if (table.getIndexType() == IndexType.LOCAL) {
ScanUtil.setLocalIndex(scan);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
index c1a3b1d..25d9fb3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/HashJoinPlan.java
@@ -23,6 +23,7 @@ import static org.apache.phoenix.util.NumberUtil.add;
import static org.apache.phoenix.util.NumberUtil.getMin;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
@@ -542,7 +543,8 @@ public class HashJoinPlan extends DelegateQueryPlan {
final byte[] cacheId;
String queryString = plan.getStatement().toString().replaceAll("\\$[0-9]+", "\\$");
if (usePersistentCache) {
- cacheId = Arrays.copyOfRange(digest.digest(queryString.getBytes()), 0, 8);
+ cacheId = Arrays.copyOfRange(digest.digest(
+ queryString.getBytes(StandardCharsets.UTF_8)), 0, 8);
boolean retrying = parent.delegate.getContext().getRetryingPersistentCache(Bytes.toLong(cacheId));
if (!retrying) {
try {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java
index e68bff0..6386a23 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/LikeExpression.java
@@ -56,13 +56,21 @@ public abstract class LikeExpression extends BaseCompoundExpression {
private static final String ZERO_OR_MORE = "\\E.*\\Q";
private static final String ANY_ONE = "\\E.\\Q";
+ private static final String[] LIKE_ESCAPE_SEQS;
+ private static final String[] LIKE_UNESCAPED_SEQS;
+
+ static {
+ LIKE_ESCAPE_SEQS = StringUtil.getLikeEscapeSeqs();
+ LIKE_UNESCAPED_SEQS = StringUtil.getLikeUnescapedSeqs();
+ }
+
/**
* Store whether this like expression has to be case sensitive or not.
*/
private LikeType likeType;
public static String unescapeLike(String s) {
- return StringUtil.replace(s, StringUtil.LIKE_ESCAPE_SEQS, StringUtil.LIKE_UNESCAPED_SEQS);
+ return StringUtil.replace(s, LIKE_ESCAPE_SEQS, LIKE_UNESCAPED_SEQS);
}
/**
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
index 52db52c..21eb2fe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
@@ -35,7 +35,7 @@ import org.apache.phoenix.schema.tuple.Tuple;
import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.SchemaUtil;
-public class ProjectedColumnExpression extends ColumnExpression {
+public class ProjectedColumnExpression extends ColumnExpression implements Cloneable {
private KeyValueSchema schema;
private ValueBitSet bitSet;
private int position;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java
index 38c3060..0583f35 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/BaseDecimalStddevAggregator.java
@@ -71,8 +71,7 @@ public abstract class BaseDecimalStddevAggregator extends DistinctValueWithCount
}
BigDecimal result = new BigDecimal(Math.sqrt(ssd.doubleValue()), new MathContext(resultPrecision,
RoundingMode.HALF_UP));
- result.setScale(this.colScale, RoundingMode.HALF_UP);
- cachedResult = result;
+ cachedResult = result.setScale(this.colScale, RoundingMode.HALF_UP);
}
if (buffer == null) {
initBuffer();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
index f647c45..298877e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.expression.aggregator;
import java.io.IOException;
+import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.TreeMap;
@@ -141,11 +142,11 @@ public class FirstLastValueServerAggregator extends BaseAggregator {
+ " is ascending: " + isAscending + " value=");
if (useOffset) {
for (byte[] key : topValues.keySet()) {
- out.append(topValues.get(key));
+ out.append(Arrays.asList(topValues.get(key)));
}
out.append(" offset = ").append(offset);
} else {
- out.append(topValue);
+ out.append(Arrays.asList(topValue));
}
return out.toString();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayFillFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayFillFunction.java
index c8db7f9..996be3d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayFillFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/function/ArrayFillFunction.java
@@ -59,7 +59,7 @@ public class ArrayFillFunction extends ScalarFunction {
Arrays.fill(elements, element);
PhoenixArray array = PDataType.instantiatePhoenixArray(getElementExpr().getDataType(), elements);
//When max length of a char array is not the max length of the element passed in
- if (getElementExpr().getDataType().isFixedWidth() && getMaxLength() != null && getMaxLength() != array.getMaxLength()) {
+ if (getElementExpr().getDataType().isFixedWidth() && getMaxLength() != null && !getMaxLength().equals(array.getMaxLength())) {
array = new PhoenixArray(array, getMaxLength());
}
ptr.set(((PArrayDataType) getDataType()).toBytes(array, getElementExpr().getDataType(), getElementExpr().getSortOrder()));
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/util/regex/JONIPattern.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/util/regex/JONIPattern.java
index 0ac33af..d9bb54d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/util/regex/JONIPattern.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/util/regex/JONIPattern.java
@@ -52,7 +52,7 @@ public class JONIPattern extends AbstractBasePattern implements AbstractBaseSpli
public JONIPattern(String patternString, int flags, Encoding coding) {
this.patternString = patternString;
if (patternString != null) {
- byte[] bytes = patternString.getBytes();
+ byte[] bytes = patternString.getBytes(coding.getCharset());
pattern = new Regex(bytes, 0, bytes.length, flags, coding, Syntax.Java);
} else {
pattern = null;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/TrackingParallelWriterIndexCommitter.java b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/TrackingParallelWriterIndexCommitter.java
index 1b6661d..d35c7a5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/TrackingParallelWriterIndexCommitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/write/TrackingParallelWriterIndexCommitter.java
@@ -254,7 +254,7 @@ public class TrackingParallelWriterIndexCommitter implements IndexCommitter {
throw exception;
} else {
exception = new MultiIndexWriteFailureException(Collections.unmodifiableList(failedTables),
- disableIndexOnFailure && PhoenixIndexFailurePolicy.getDisableIndexOnFailure(env), cause);
+ false, cause);
throw wrapInDoNotRetryIOException("At least one index write failed after retries", exception,
EnvironmentEdgeManager.currentTimeMillis());
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java
index 9570dc5..5fbce2c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/PhoenixIndexCodec.java
@@ -44,7 +44,7 @@ public class PhoenixIndexCodec extends BaseIndexCodec {
public static final String INDEX_PROTO_MD = "IdxProtoMD";
public static final String INDEX_UUID = "IdxUUID";
public static final String INDEX_MAINTAINERS = "IndexMaintainers";
- public static KeyValueBuilder KV_BUILDER = GenericKeyValueBuilder.INSTANCE;
+ public static final KeyValueBuilder KV_BUILDER = GenericKeyValueBuilder.INSTANCE;
private byte[] tableName;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/NonAggregateRegionScannerFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/iterate/NonAggregateRegionScannerFactory.java
index 2a541c0..a07b6a9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/NonAggregateRegionScannerFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/NonAggregateRegionScannerFactory.java
@@ -138,7 +138,7 @@ public class NonAggregateRegionScannerFactory extends RegionScannerFactory {
}
int clientVersion = ScanUtil.getClientVersion(scan);
List<IndexMaintainer> indexMaintainers =
- localIndexBytes == null ? null : IndexMaintainer.deserialize(localIndexBytes, useProto);
+ IndexMaintainer.deserialize(localIndexBytes, useProto);
indexMaintainer = indexMaintainers.get(0);
viewConstants = IndexUtil.deserializeViewConstantsFromScan(scan);
byte[] txState = scan.getAttribute(BaseScannerRegionObserver.TX_STATE);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
index 105f45b..7c3b8cc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
@@ -176,6 +176,7 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea
private LogLevel auditLogLevel;
private Double logSamplingRate;
private String sourceOfOperation;
+ private static final String[] CONNECTION_PROPERTIES;
private final ConcurrentLinkedQueue<PhoenixConnection> childConnections =
new ConcurrentLinkedQueue<>();
@@ -186,6 +187,7 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea
static {
Tracing.addTraceMetricsSource();
+ CONNECTION_PROPERTIES = PhoenixRuntime.getConnectionProperties();
}
private static Properties newPropsWithSCN(long scn, Properties props) {
@@ -265,8 +267,7 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea
}
// Copy so client cannot change
- this.info = info == null ? new Properties() : PropertiesUtil
- .deepCopy(info);
+ this.info = PropertiesUtil.deepCopy(info);
final PName tenantId = JDBCUtil.getTenantId(url, info);
if (this.info.isEmpty() && tenantId == null) {
this.services = services;
@@ -438,7 +439,7 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea
private static Properties filterKnownNonProperties(Properties info) {
Properties prunedProperties = info;
- for (String property : PhoenixRuntime.CONNECTION_PROPERTIES) {
+ for (String property : CONNECTION_PROPERTIES) {
if (info.containsKey(property)) {
if (prunedProperties == info) {
prunedProperties = PropertiesUtil.deepCopy(info);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
index 59d8add..83d8d85 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixPreparedStatement.java
@@ -124,11 +124,6 @@ public class PhoenixPreparedStatement extends PhoenixStatement implements Prepar
parameterCount + " bind parameters are defined")
.build().buildException();
}
- if (parameterIndex < 1) {
- throw new SQLExceptionInfo.Builder(SQLExceptionCode.PARAM_INDEX_OUT_OF_BOUND)
- .setMessage("Invalid bind parameter index " + parameterIndex)
- .build().buildException();
- }
this.parameters.set(parameterIndex - 1, value);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/CsvBulkImportUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/CsvBulkImportUtil.java
index 21787b2..f3141ed 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/CsvBulkImportUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/CsvBulkImportUtil.java
@@ -17,6 +17,7 @@
*/
package org.apache.phoenix.mapreduce;
+import java.nio.charset.StandardCharsets;
import java.util.Base64;
import org.apache.hadoop.conf.Configuration;
@@ -69,10 +70,10 @@ public class CsvBulkImportUtil {
}
@VisibleForTesting
-
static void setChar(Configuration conf, String confKey, Character charValue) {
if(charValue!=null) {
- conf.set(confKey, Bytes.toString(Base64.getEncoder().encode(charValue.toString().getBytes())));
+ conf.set(confKey, Bytes.toString(Base64.getEncoder().encode(
+ charValue.toString().getBytes(StandardCharsets.UTF_8))));
}
}
@@ -82,7 +83,8 @@ public class CsvBulkImportUtil {
if (strValue == null) {
return null;
}
- return new String(Base64.getDecoder().decode(strValue)).charAt(0);
+ return new String(Base64.getDecoder().decode(strValue.getBytes(StandardCharsets.UTF_8)),
+ StandardCharsets.UTF_8).charAt(0);
}
public static Path getOutputPath(Path outputdir, String tableName) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/MultiHfileOutputFormat.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/MultiHfileOutputFormat.java
index 7aec4ee..3a9071e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/MultiHfileOutputFormat.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/MultiHfileOutputFormat.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -79,6 +80,8 @@ import org.apache.phoenix.util.EnvironmentEdgeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
import org.apache.phoenix.thirdparty.com.google.common.collect.Sets;
@@ -447,7 +450,7 @@ public class MultiHfileOutputFormat extends FileOutputFormat<TableRowkeyPair, Ce
continue;
}
try {
- confValMap.put(URLDecoder.decode(familySplit[0], "UTF-8").getBytes(),
+ confValMap.put(URLDecoder.decode(familySplit[0], "UTF-8").getBytes(StandardCharsets.UTF_8),
URLDecoder.decode(familySplit[1], "UTF-8"));
} catch (UnsupportedEncodingException e) {
// will not happen with UTF-8 encoding
@@ -478,6 +481,8 @@ public class MultiHfileOutputFormat extends FileOutputFormat<TableRowkeyPair, Ce
TotalOrderPartitioner.setPartitionFile(conf, partitionsPath);
}
+ @SuppressWarnings(value="EC_ARRAY_AND_NONARRAY",
+ justification="ImmutableBytesWritable DOES implement equals(byte])")
private static void writePartitions(Configuration conf, Path partitionsPath,
Set<TableRowkeyPair> tablesStartKeys) throws IOException {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
index 563d69b..f169822 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/OrphanViewTool.java
@@ -31,9 +31,14 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.VIEW_TYPE;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -229,7 +234,7 @@ public class OrphanViewTool extends Configured implements Tool {
IDENTIFY_ORPHAN_VIEWS_OPTION.getOpt() + " or " + CLEAN_ORPHAN_VIEWS_OPTION.getOpt());
}
if (cmdLine.hasOption(AGE_OPTION.getOpt())) {
- ageMs = Long.valueOf(cmdLine.getOptionValue(AGE_OPTION.getOpt()));
+ ageMs = Long.parseLong(cmdLine.getOptionValue(AGE_OPTION.getOpt()));
}
outputPath = cmdLine.getOptionValue(OUTPUT_PATH_OPTION.getOpt());
@@ -769,7 +774,8 @@ public class OrphanViewTool extends Configured implements Tool {
private void readOrphanViews() throws Exception {
String aLine;
- reader[VIEW] = new BufferedReader(new FileReader(inputPath + fileName[VIEW]));
+ reader[VIEW] = new BufferedReader(new InputStreamReader(
+ new FileInputStream(inputPath + fileName[VIEW]), StandardCharsets.UTF_8));
while ((aLine = reader[VIEW].readLine()) != null) {
Key key = new Key(aLine);
orphanViewSet.put(key, new View(key));
@@ -779,7 +785,8 @@ public class OrphanViewTool extends Configured implements Tool {
private void readAndRemoveOrphanLinks(PhoenixConnection phoenixConnection) throws Exception{
String aLine;
for (byte i = VIEW+1; i < ORPHAN_TYPE_COUNT; i++) {
- reader[i] = new BufferedReader(new FileReader(inputPath + fileName[i]));
+ reader[i] = new BufferedReader(new InputStreamReader(
+ new FileInputStream(inputPath + fileName[i]), StandardCharsets.UTF_8));
while ((aLine = reader[i].readLine()) != null) {
String ends[] = aLine.split("-->");
removeLink(phoenixConnection, new Key(ends[0]), new Key(ends[1]), getLinkType(i));
@@ -842,7 +849,8 @@ public class OrphanViewTool extends Configured implements Tool {
file.delete();
}
file.createNewFile();
- writer[i] = new BufferedWriter(new FileWriter(file));
+ writer[i] = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file), StandardCharsets.UTF_8));
}
}
Properties props = new Properties();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
index be20cc6..c294fed 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixInputFormat.java
@@ -202,7 +202,7 @@ public class PhoenixInputFormat<T extends DBWritable> extends InputFormat<NullWr
// since we can't set a scn on connections with txn set TX_SCN attribute so that the max time range is set by BaseScannerRegionObserver
if (txnScnValue != null) {
- scan.setAttribute(BaseScannerRegionObserver.TX_SCN, Bytes.toBytes(Long.valueOf(txnScnValue)));
+ scan.setAttribute(BaseScannerRegionObserver.TX_SCN, Bytes.toBytes(Long.parseLong(txnScnValue)));
}
// setting the snapshot configuration
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixServerBuildIndexInputFormat.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixServerBuildIndexInputFormat.java
index 536f889..1052b30 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixServerBuildIndexInputFormat.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixServerBuildIndexInputFormat.java
@@ -150,15 +150,15 @@ public class PhoenixServerBuildIndexInputFormat<T extends DBWritable> extends Ph
try (final Connection connection = ConnectionUtil.getInputConnection(configuration, overridingProps)) {
PhoenixConnection phoenixConnection = connection.unwrap(PhoenixConnection.class);
- Long scn = (currentScnValue != null) ? Long.valueOf(currentScnValue) : EnvironmentEdgeManager.currentTimeMillis();
+ Long scn = (currentScnValue != null) ? Long.parseLong(currentScnValue) : EnvironmentEdgeManager.currentTimeMillis();
setCurrentScnValue(configuration, scn);
- Long startTime = (startTimeValue == null) ? 0L : Long.valueOf(startTimeValue);
+ Long startTime = (startTimeValue == null) ? 0L : Long.parseLong(startTimeValue);
queryPlan = queryPlanBuilder.getQueryPlan(phoenixConnection, dataTableFullName, indexTableFullName);
Scan scan = queryPlan.getContext().getScan();
- Long lastVerifyTimeValue = lastVerifyTime == null ? 0L : Long.valueOf(lastVerifyTime);
+ Long lastVerifyTimeValue = lastVerifyTime == null ? 0L : Long.parseLong(lastVerifyTime);
try {
scan.setTimeRange(startTime, scn);
scan.setAttribute(BaseScannerRegionObserver.INDEX_REBUILD_PAGING, TRUE_BYTES);
@@ -167,7 +167,7 @@ public class PhoenixServerBuildIndexInputFormat<T extends DBWritable> extends Ph
configuration.get(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS);
if (rebuildPageRowSize != null) {
scan.setAttribute(BaseScannerRegionObserver.INDEX_REBUILD_PAGE_ROWS,
- Bytes.toBytes(Long.valueOf(rebuildPageRowSize)));
+ Bytes.toBytes(Long.parseLong(rebuildPageRowSize)));
}
scan.setAttribute(BaseScannerRegionObserver.INDEX_REBUILD_VERIFY_TYPE, getIndexVerifyType(configuration).toBytes());
scan.setAttribute(BaseScannerRegionObserver.INDEX_RETRY_VERIFY, Bytes.toBytes(lastVerifyTimeValue));
@@ -184,7 +184,7 @@ public class PhoenixServerBuildIndexInputFormat<T extends DBWritable> extends Ph
}
// since we can't set a scn on connections with txn set TX_SCN attribute so that the max time range is set by BaseScannerRegionObserver
if (txnScnValue != null) {
- scan.setAttribute(BaseScannerRegionObserver.TX_SCN, Bytes.toBytes(Long.valueOf(txnScnValue)));
+ scan.setAttribute(BaseScannerRegionObserver.TX_SCN, Bytes.toBytes(Long.parseLong(txnScnValue)));
}
return queryPlan;
} catch (Exception exception) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
index f42feda..9985379 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/bulkload/TargetTableRefFunctions.java
@@ -31,7 +31,7 @@ import org.apache.phoenix.util.JacksonUtil;
*/
public class TargetTableRefFunctions {
- public static Function<TargetTableRef,String> TO_JSON = new Function<TargetTableRef,String>() {
+ public static final Function<TargetTableRef,String> TO_JSON = new Function<TargetTableRef,String>() {
@Override
public String apply(TargetTableRef input) {
@@ -44,7 +44,7 @@ public class TargetTableRefFunctions {
}
};
- public static Function<String,TargetTableRef> FROM_JSON = new Function<String,TargetTableRef>() {
+ public static final Function<String,TargetTableRef> FROM_JSON = new Function<String,TargetTableRef>() {
@Override
public TargetTableRef apply(String json) {
@@ -57,7 +57,7 @@ public class TargetTableRefFunctions {
}
};
- public static Function<List<TargetTableRef>,String> NAMES_TO_JSON = new Function<List<TargetTableRef>,String>() {
+ public static final Function<List<TargetTableRef>,String> NAMES_TO_JSON = new Function<List<TargetTableRef>,String>() {
@Override
public String apply(List<TargetTableRef> input) {
@@ -74,7 +74,7 @@ public class TargetTableRefFunctions {
}
};
- public static Function<List<TargetTableRef>,String> LOGICAL_NAMES_TO_JSON = new Function<List<TargetTableRef>,String>() {
+ public static final Function<List<TargetTableRef>,String> LOGICAL_NAMES_TO_JSON = new Function<List<TargetTableRef>,String>() {
@Override
public String apply(List<TargetTableRef> input) {
@@ -91,7 +91,7 @@ public class TargetTableRefFunctions {
}
};
- public static Function<String,List<String>> NAMES_FROM_JSON = new Function<String,List<String>>() {
+ public static final Function<String,List<String>> NAMES_FROM_JSON = new Function<String,List<String>>() {
@SuppressWarnings("unchecked")
@Override
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
index 79f0909..6f3ca2c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyMapper.java
@@ -112,7 +112,7 @@ public class IndexScrutinyMapper extends Mapper<NullWritable, PhoenixIndexDBWrit
final Properties overrideProps = new Properties();
String scn = configuration.get(PhoenixConfigurationUtil.CURRENT_SCN_VALUE);
overrideProps.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, scn);
- scnTimestamp = new Long(scn);
+ scnTimestamp = Long.parseLong(scn);
connection = ConnectionUtil.getOutputConnection(configuration, overrideProps);
connection.setAutoCommit(false);
batchSize = PhoenixConfigurationUtil.getScrutinyBatchSize(configuration);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTableOutput.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTableOutput.java
index b2075dc..6a2aa90 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTableOutput.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTableOutput.java
@@ -54,7 +54,7 @@ public class IndexScrutinyTableOutput {
* This table holds the invalid rows in the source table (either missing a target, or a bad
* covered column value). Dynamic columns hold the original source and target table column data.
*/
- public static String OUTPUT_TABLE_NAME = "PHOENIX_INDEX_SCRUTINY";
+ public static final String OUTPUT_TABLE_NAME = "PHOENIX_INDEX_SCRUTINY";
public static final String SCRUTINY_EXECUTE_TIME_COL_NAME = "SCRUTINY_EXECUTE_TIME";
public static final String TARGET_TABLE_COL_NAME = "TARGET_TABLE";
public static final String SOURCE_TABLE_COL_NAME = "SOURCE_TABLE";
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
index ed04865..1f775d6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexScrutinyTool.java
@@ -323,7 +323,6 @@ public class IndexScrutinyTool extends Configured implements Tool {
// root dir not a subdirectory of hbase dir
Path rootDir = new Path("hdfs:///index-snapshot-dir");
CommonFSUtils.setRootDir(configuration, rootDir);
- Path restoreDir = new Path(CommonFSUtils.getRootDir(configuration), "restore-dir");
// set input for map reduce job using hbase snapshots
//PhoenixMapReduceUtil.setInput(job, PhoenixIndexDBWritable.class, snapshotName,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
index fbb9b18..34d8b1c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexTool.java
@@ -571,7 +571,7 @@ public class IndexTool extends Configured implements Tool {
if (pDataTable.isTransactional()) {
long maxTimeRange = pDataTable.getTimeStamp() + 1;
scan.setAttribute(BaseScannerRegionObserver.TX_SCN,
- Bytes.toBytes(Long.valueOf(Long.toString(TransactionUtil.convertToNanoseconds(maxTimeRange)))));
+ Bytes.toBytes(TransactionUtil.convertToNanoseconds(maxTimeRange)));
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
index ba7d957..f42d705 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexUpgradeTool.java
@@ -67,6 +67,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.phoenix.util.SchemaUtil;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Connection;
@@ -321,7 +322,8 @@ public class IndexUpgradeTool extends Configured implements Tool {
prop.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName());
if (inputTables == null) {
- inputTables = new String(Files.readAllBytes(Paths.get(inputFile)));
+ inputTables = new String(
+ Files.readAllBytes(Paths.get(inputFile)), StandardCharsets.UTF_8);
}
if (inputTables == null) {
LOGGER.severe("Tables' list is not available; use -tb or -f option");
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
index 74038e8..a0cd037 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationOutputRepository.java
@@ -76,7 +76,7 @@ public class IndexVerificationOutputRepository implements AutoCloseable {
public static final String ERROR_TYPE = "ErrorType";
public static final byte[] ERROR_TYPE_BYTES = Bytes.toBytes(ERROR_TYPE);
- public static String VERIFICATION_PHASE = "Phase";
+ public static final String VERIFICATION_PHASE = "Phase";
public final static byte[] VERIFICATION_PHASE_BYTES = Bytes.toBytes(VERIFICATION_PHASE);
public final static String EXPECTED_VALUE = "ExpectedValue";
public final static byte[] EXPECTED_VALUE_BYTES = Bytes.toBytes(EXPECTED_VALUE);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
index 55b7d3b..9ff5ed0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/IndexVerificationResultRepository.java
@@ -115,14 +115,14 @@ public class IndexVerificationResultRepository implements AutoCloseable {
public final static byte[] AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT_BYTES =
Bytes.toBytes(AFTER_REBUILD_BEYOND_MAXLOOKBACK_INVALID_INDEX_ROW_COUNT);
- public static String BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS = "BeforeRebuildInvalidIndexRowCountCozExtraCells";
- public final static byte[] BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS_BYTES = Bytes.toBytes(BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS);
- public static String BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS = "BeforeRebuildInvalidIndexRowCountCozMissingCells";
- public final static byte[] BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS_BYTES = Bytes.toBytes(BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS);
+ public final static String BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS = "BeforeRebuildInvalidIndexRowCountCozExtraCells";
+ public final static byte[] BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS_BYTES = Bytes.toBytes(BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS);
+ public final static String BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS = "BeforeRebuildInvalidIndexRowCountCozMissingCells";
+ public final static byte[] BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS_BYTES = Bytes.toBytes(BEFORE_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS);
- public static String AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS = "AfterRebuildInvalidIndexRowCountCozExtraCells";
+ public final static String AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS = "AfterRebuildInvalidIndexRowCountCozExtraCells";
public final static byte[] AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS_BYTES = Bytes.toBytes(AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_EXTRA_CELLS);
- public static String AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS = "AfterRebuildInvalidIndexRowCountCozMissingCells";
+ public final static String AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS = "AfterRebuildInvalidIndexRowCountCozMissingCells";
public final static byte[] AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS_BYTES = Bytes.toBytes(AFTER_REBUILD_INVALID_INDEX_ROW_COUNT_COZ_MISSING_CELLS);
public final static String BEFORE_REPAIR_EXTRA_VERIFIED_INDEX_ROW_COUNT = "BeforeRepairExtraVerifiedIndexRowCount";
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectMapper.java
index eca3a9e..d4c9798 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectMapper.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.mapreduce.index;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
@@ -172,8 +173,9 @@ public class PhoenixIndexImportDirectMapper extends
}
// We are writing some dummy key-value as map output here so that we commit only one
// output to reducer.
- context.write(new ImmutableBytesWritable(UUID.randomUUID().toString().getBytes()),
- new IntWritable(0));
+ context.write(new ImmutableBytesWritable(
+ UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8)),
+ new IntWritable(0));
super.cleanup(context);
} catch (SQLException e) {
LOGGER.error(" Error {} while read/write of a record ", e.getMessage());
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
index ab13729..2724990 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexImportDirectReducer.java
@@ -63,7 +63,7 @@ public class PhoenixIndexImportDirectReducer extends
throws IOException {
Configuration configuration = context.getConfiguration();
try (final Connection connection = ConnectionUtil.getInputConnection(configuration)) {
- long ts = Long.valueOf(configuration.get(PhoenixConfigurationUtil.CURRENT_SCN_VALUE));
+ long ts = Long.parseLong(configuration.get(PhoenixConfigurationUtil.CURRENT_SCN_VALUE));
IndexToolVerificationResult verificationResult =
resultRepository.getVerificationResult(connection, ts, indexTableNameBytes);
context.getCounter(PhoenixIndexToolJobCounters.SCANNED_DATA_ROW_COUNT).
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexPartialBuildMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexPartialBuildMapper.java
index ca5d240..fd4651e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexPartialBuildMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixIndexPartialBuildMapper.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.mapreduce.index;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
@@ -164,8 +165,9 @@ public class PhoenixIndexPartialBuildMapper extends TableMapper<ImmutableBytesWr
}
// We are writing some dummy key-value as map output here so that we commit only one
// output to reducer.
- context.write(new ImmutableBytesWritable(UUID.randomUUID().toString().getBytes()),
- new IntWritable(0));
+ context.write(new ImmutableBytesWritable(
+ UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8)),
+ new IntWritable(0));
super.cleanup(context);
} catch (SQLException e) {
LOGGER.error(" Error {} while read/write of a record ", e.getMessage());
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixServerBuildIndexMapper.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixServerBuildIndexMapper.java
index 7a75cf6..8cdcb6a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixServerBuildIndexMapper.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/PhoenixServerBuildIndexMapper.java
@@ -18,6 +18,7 @@
package org.apache.phoenix.mapreduce.index;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.UUID;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -41,7 +42,7 @@ public class PhoenixServerBuildIndexMapper extends
String rebuildPageRowSizeConf =
context.getConfiguration().get(QueryServices.INDEX_REBUILD_PAGE_SIZE_IN_ROWS);
if (rebuildPageRowSizeConf != null) {
- this.rebuildPageRowSize = Long.valueOf(rebuildPageRowSizeConf);
+ this.rebuildPageRowSize = Long.parseLong(rebuildPageRowSizeConf);
} else {
this.rebuildPageRowSize = -1L;
}
@@ -63,7 +64,9 @@ public class PhoenixServerBuildIndexMapper extends
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
- context.write(new ImmutableBytesWritable(UUID.randomUUID().toString().getBytes()), new IntWritable(0));
+ context.write(new ImmutableBytesWritable(
+ UUID.randomUUID().toString().getBytes(StandardCharsets.UTF_8)),
+ new IntWritable(0));
super.cleanup(context);
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
index 82959fc..93fa57c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
@@ -298,7 +298,6 @@ public class PhoenixMRJobSubmitter {
toScheduleJobs.remove(candidateJobs.get(jobId));
}
}
- toScheduleJobs.removeAll(submittedJobs);
return toScheduleJobs;
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/DefaultMultiViewSplitStrategy.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/DefaultMultiViewSplitStrategy.java
index 79808ca..62e5150 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/DefaultMultiViewSplitStrategy.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/DefaultMultiViewSplitStrategy.java
@@ -55,7 +55,7 @@ public class DefaultMultiViewSplitStrategy implements MultiViewSplitStrategy {
*/
public int getNumberOfMappers(int viewSize, int numViewsInSplit) {
int numberOfMappers = viewSize / numViewsInSplit;
- if (Math.ceil(viewSize % numViewsInSplit) > 0) {
+ if (viewSize % numViewsInSplit > 0) {
numberOfMappers++;
}
return numberOfMappers;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
index 737c2ef..f17510e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
@@ -463,7 +463,7 @@ public final class PhoenixConfigurationUtil {
public static int getMultiViewQueryMoreSplitSize(final Configuration configuration) {
final String batchSize = configuration.get(MAPREDUCE_MULTI_INPUT_QUERY_BATCH_SIZE);
Preconditions.checkNotNull(batchSize);
- return Integer.valueOf(batchSize);
+ return Integer.parseInt(batchSize);
}
public static List<ColumnInfo> getSelectColumnMetadataList(final Configuration configuration) throws SQLException {
@@ -493,7 +493,7 @@ public final class PhoenixConfigurationUtil {
public static int getMultiViewSplitSize(final Configuration configuration) {
final String splitSize = configuration.get(MAPREDUCE_MULTI_INPUT_MAPPER_SPLIT_SIZE);
Preconditions.checkNotNull(splitSize);
- return Integer.valueOf(splitSize);
+ return Integer.parseInt(splitSize);
}
private static List<String> getSelectColumnList(
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetric.java b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetric.java
index 103fd14..07cd25d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetric.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetric.java
@@ -17,8 +17,6 @@
*/
package org.apache.phoenix.monitoring;
-
-
/**
* Interface for representing a metric that could be published and possibly combined with a metric of the same
* type.
@@ -31,9 +29,9 @@ public interface CombinableMetric extends Metric {
CombinableMetric clone();
- public class NoOpRequestMetric implements CombinableMetric {
+ public class NoOpRequestMetric implements CombinableMetric, Cloneable {
- public static NoOpRequestMetric INSTANCE = new NoOpRequestMetric();
+ public static final NoOpRequestMetric INSTANCE = new NoOpRequestMetric();
private static final String EMPTY_STRING = "";
@Override
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetricImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetricImpl.java
index bd22418..40cb516 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetricImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/CombinableMetricImpl.java
@@ -17,7 +17,7 @@
*/
package org.apache.phoenix.monitoring;
-public class CombinableMetricImpl implements CombinableMetric {
+public class CombinableMetricImpl implements CombinableMetric, Cloneable {
private final Metric metric;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/TableMetricsManager.java b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/TableMetricsManager.java
index 4688137..f3c626b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/monitoring/TableMetricsManager.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/monitoring/TableMetricsManager.java
@@ -31,6 +31,8 @@ import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
/**
* Central place where we keep track of all the Table Level metrics. Register each tableMetrics and
* store the instance of it associated with TableName in a map
@@ -53,6 +55,8 @@ public class TableMetricsManager {
private static volatile MetricPublisherSupplierFactory mPublisher = null;
private static volatile QueryServicesOptions options = null;
+ @SuppressWarnings(value="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD",
+ justification="This is how we implement the singleton pattern")
public TableMetricsManager(QueryServicesOptions ops) {
options = ops;
isTableLevelMetricsEnabled = options.isTableLevelMetricsEnabled();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/optimize/Cost.java b/phoenix-core/src/main/java/org/apache/phoenix/optimize/Cost.java
index b83f354..788e4b9 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/Cost.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/Cost.java
@@ -26,7 +26,7 @@ import java.util.Objects;
*/
public class Cost implements Comparable<Cost> {
/** The unknown cost. */
- public static Cost UNKNOWN = new Cost(Double.NaN, Double.NaN, Double.NaN) {
+ public static final Cost UNKNOWN = new Cost(Double.NaN, Double.NaN, Double.NaN) {
@Override
public String toString() {
return "{unknown}";
@@ -34,7 +34,7 @@ public class Cost implements Comparable<Cost> {
};
/** The zero cost. */
- public static Cost ZERO = new Cost(0, 0, 0) {
+ public static final Cost ZERO = new Cost(0, 0, 0) {
@Override
public String toString() {
return "{zero}";
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ChangePermsStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ChangePermsStatement.java
index 0eae26f..b49183d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/ChangePermsStatement.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ChangePermsStatement.java
@@ -23,6 +23,7 @@ import org.apache.phoenix.exception.PhoenixParserException;
import org.apache.phoenix.jdbc.PhoenixStatement;
import org.apache.phoenix.util.SchemaUtil;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
/**
@@ -44,7 +45,7 @@ public class ChangePermsStatement implements BindableStatement {
// To comply with SQL standards, we may support the user given permissions to revoke specific permissions in future.
// GRANT permissions statement requires this parameter and the parsing will fail if it is not specified in SQL
if(permsString != null) {
- Permission permission = new Permission(permsString.getBytes());
+ Permission permission = new Permission(permsString.getBytes(StandardCharsets.UTF_8));
permsList = permission.getActions();
}
if(isSchemaName) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/PFunction.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/PFunction.java
index a5263ad..f914fba 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/PFunction.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/PFunction.java
@@ -101,11 +101,12 @@ public class PFunction implements PMetaDataEntity {
this.returnType = PNameFactory.newName(returnType);
this.functionKey = new PTableKey(this.tenantId, this.functionName.getString());
this.timeStamp = timeStamp;
- int estimatedSize = SizedUtil.OBJECT_SIZE * 2 + 23 * SizedUtil.POINTER_SIZE + 4 * SizedUtil.INT_SIZE + 2 * SizedUtil.LONG_SIZE + 2 * SizedUtil.INT_OBJECT_SIZE +
+ this.estimatedSize = SizedUtil.OBJECT_SIZE * 2 + 23 * SizedUtil.POINTER_SIZE +
+ 4 * SizedUtil.INT_SIZE + 2 * SizedUtil.LONG_SIZE + 2 * SizedUtil.INT_OBJECT_SIZE +
PNameFactory.getEstimatedSize(tenantId) +
PNameFactory.getEstimatedSize(this.functionName) +
PNameFactory.getEstimatedSize(this.className) +
- (jarPath==null?0:PNameFactory.getEstimatedSize(this.jarPath));
+ (jarPath == null ? 0 : PNameFactory.getEstimatedSize(this.jarPath));
this.temporary = temporary;
this.replace = replace;
}
@@ -269,6 +270,7 @@ public class PFunction implements PMetaDataEntity {
timeStamp, false, function.hasIsReplace() ? true : false);
}
+ @Override
public int getEstimatedSize() {
return estimatedSize;
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 3810fc1..3927c17 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -379,7 +379,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
private final int maxConnectionsAllowed;
private final int maxInternalConnectionsAllowed;
private final boolean shouldThrottleNumConnections;
- public static final byte[] MUTEX_LOCKED = "MUTEX_LOCKED".getBytes();
+ public static final byte[] MUTEX_LOCKED = "MUTEX_LOCKED".getBytes(StandardCharsets.UTF_8);
private static interface FeatureSupported {
boolean isSupported(ConnectionQueryServices services);
@@ -1268,7 +1268,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
if (!success) {
throw new TimeoutException("Operation " + op.getOperationName() + " didn't complete within "
+ watch.elapsedMillis() + " ms "
- + (numTries > 1 ? ("after trying " + numTries + (numTries > 1 ? "times." : "time.")) : ""));
+ + "after trying " + numTries + "times.");
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Operation "
@@ -1276,7 +1276,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
+ " completed within "
+ watch.elapsedMillis()
+ "ms "
- + (numTries > 1 ? ("after trying " + numTries + (numTries > 1 ? "times." : "time.")) : ""));
+ + "after trying " + numTries + " times." );
}
}
}
@@ -1694,7 +1694,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
+ getServerVersion(serverJarVersion));
}
}
- hasIndexWALCodec &= hasIndexWALCodec(serverJarVersion);
+ hasIndexWALCodec = hasIndexWALCodec && hasIndexWALCodec(serverJarVersion);
if (minHBaseVersion > MetaDataUtil.decodeHBaseVersion(serverJarVersion)) {
minHBaseVersion = MetaDataUtil.decodeHBaseVersion(serverJarVersion);
}
@@ -2279,7 +2279,9 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
tableProps.put(PhoenixDatabaseMetaData.IMMUTABLE_ROWS, table.isImmutableRows());
// We got the properties of the physical base table but we need to create the view index table using logical name
- byte[] viewPhysicalTableName = MetaDataUtil.getNamespaceMappedName(table.getName(), isNamespaceMapped).getBytes();
+ byte[] viewPhysicalTableName =
+ MetaDataUtil.getNamespaceMappedName(table.getName(), isNamespaceMapped)
+ .getBytes(StandardCharsets.UTF_8);
ensureViewIndexTableCreated(viewPhysicalTableName, physicalTableName, tableProps, families, splits, timestamp, isNamespaceMapped);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
index 17562d6..ce2fb1b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionlessQueryServicesImpl.java
@@ -718,10 +718,6 @@ public class ConnectionlessQueryServicesImpl extends DelegateQueryServices imple
@Override
public MetaDataMutationResult getSchema(String schemaName, long clientTimestamp) throws SQLException {
- try {
- PSchema schema = metaData.getSchema(new PTableKey(null, schemaName));
- new MetaDataMutationResult(MutationCode.SCHEMA_ALREADY_EXISTS, schema, 0);
- } catch (SchemaNotFoundException e) {}
return new MetaDataMutationResult(MutationCode.SCHEMA_NOT_FOUND, 0, null);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ITGuidePostsCacheFactory.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ITGuidePostsCacheFactory.java
index a22a650..61a9175 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ITGuidePostsCacheFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ITGuidePostsCacheFactory.java
@@ -20,7 +20,7 @@ import org.apache.phoenix.util.ReadOnlyProps;
* Test Class Only used to verify in e2e tests
*/
public class ITGuidePostsCacheFactory implements GuidePostsCacheFactory {
- public static ConcurrentHashMap<Integer, DefaultGuidePostsCacheFactory> map =
+ public static final ConcurrentHashMap<Integer, DefaultGuidePostsCacheFactory> map =
new ConcurrentHashMap<>();
private static AtomicInteger count = new AtomicInteger();
private Integer key;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
index 32b14dc..7002fbf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryConstants.java
@@ -19,6 +19,7 @@ package org.apache.phoenix.query;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
@@ -466,8 +467,8 @@ public interface QueryConstants {
ImmutableStorageScheme.SINGLE_CELL_ARRAY_WITH_OFFSETS.name() + ",\n" +
TableProperty.COLUMN_ENCODED_BYTES.toString()+" = 1";
- byte[] OFFSET_FAMILY = "f_offset".getBytes();
- byte[] OFFSET_COLUMN = "c_offset".getBytes();
+ byte[] OFFSET_FAMILY = "f_offset".getBytes(StandardCharsets.UTF_8);
+ byte[] OFFSET_COLUMN = "c_offset".getBytes(StandardCharsets.UTF_8);
String LAST_SCAN = "LAST_SCAN";
String HASH_JOIN_CACHE_RETRIES = "hashjoin.client.retries.number";
int DEFAULT_HASH_JOIN_CACHE_RETRIES = 5;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
index e1c3303..930e5dc 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/QueryServicesOptions.java
@@ -187,7 +187,7 @@ public class QueryServicesOptions {
// Spillable GroupBy - SPGBY prefix
//
// Enable / disable spillable group by
- public static boolean DEFAULT_GROUPBY_SPILLABLE = true;
+ public static final boolean DEFAULT_GROUPBY_SPILLABLE = true;
// Number of spill files / partitions the keys are distributed to
// Each spill file fits 2GB of data
public static final int DEFAULT_GROUPBY_SPILL_FILES = 2;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index c85e220..eb719f0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -119,6 +119,7 @@ import static org.apache.phoenix.schema.types.PDataType.FALSE_BYTES;
import static org.apache.phoenix.schema.types.PDataType.TRUE_BYTES;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -275,6 +276,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps;
import org.apache.phoenix.thirdparty.com.google.common.collect.Sets;
import org.apache.phoenix.thirdparty.com.google.common.primitives.Ints;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
public class MetaDataClient {
private static final Logger LOGGER = LoggerFactory.getLogger(MetaDataClient.class);
@@ -2089,7 +2092,8 @@ public class MetaDataClient {
// TODO: PHOENIX_TABLE_TTL
if (tableType == VIEW && parentPhysicalName != null) {
- TableDescriptor desc = connection.getQueryServices().getTableDescriptor(parentPhysicalName.getBytes());
+ TableDescriptor desc = connection.getQueryServices().getTableDescriptor(
+ parentPhysicalName.getBytes(StandardCharsets.UTF_8));
if (desc != null) {
Integer tableTTLProp = desc.getColumnFamily(SchemaUtil.getEmptyColumnFamily(parent)).getTimeToLive();
if ((tableTTLProp != null) && (tableTTLProp != HConstants.FOREVER)) {
@@ -3022,7 +3026,7 @@ public class MetaDataClient {
}
tableUpsert.setBoolean(24, isAppendOnlySchema);
if (guidePostsWidth == null) {
- tableUpsert.setNull(25, Types.BIGINT);
+ tableUpsert.setNull(25, Types.BIGINT);
} else {
tableUpsert.setLong(25, guidePostsWidth);
}
@@ -3177,10 +3181,8 @@ public class MetaDataClient {
.setNamespaceMapped(isNamespaceMapped)
.setAutoPartitionSeqName(autoPartitionSeq)
.setAppendOnlySchema(isAppendOnlySchema)
- .setImmutableStorageScheme(immutableStorageScheme == null ?
- ImmutableStorageScheme.ONE_CELL_PER_COLUMN : immutableStorageScheme)
- .setQualifierEncodingScheme(encodingScheme == null ?
- QualifierEncodingScheme.NON_ENCODED_QUALIFIERS : encodingScheme)
+ .setImmutableStorageScheme(immutableStorageScheme)
+ .setQualifierEncodingScheme(encodingScheme)
.setBaseColumnCount(baseTableColumnCount)
.setEncodedCQCounter(cqCounterToBe)
.setUseStatsForParallelization(useStatsForParallelizationProp)
@@ -3196,8 +3198,7 @@ public class MetaDataClient {
.setIndexes(Collections.<PTable>emptyList())
.setParentSchemaName((parent == null) ? null : parent.getSchemaName())
.setParentTableName((parent == null) ? null : parent.getTableName())
- .setPhysicalNames(physicalNames == null ?
- ImmutableList.<PName>of() : ImmutableList.copyOf(physicalNames))
+ .setPhysicalNames(ImmutableList.copyOf(physicalNames))
.setColumns(columns.values())
.setPhoenixTTL(phoenixTTL == null ? PHOENIX_TTL_NOT_DEFINED : phoenixTTL)
.setPhoenixTTLHighWaterMark(phoenixTTLHighWaterMark == null ? MIN_PHOENIX_TTL_HWM : phoenixTTLHighWaterMark)
@@ -4147,7 +4148,8 @@ public class MetaDataClient {
connection.rollback();
}
- byte[] family = families.size() > 0 ? families.iterator().next().getBytes() : null;
+ byte[] family = families.size() > 0 ?
+ families.iterator().next().getBytes(StandardCharsets.UTF_8) : null;
// Figure out if the empty column family is changing as a result of adding the new column
byte[] emptyCF = null;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
index f172a0b..d43d2aa 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PMetaDataImpl.java
@@ -195,7 +195,7 @@ public class PMetaDataImpl implements PMetaData {
PTableImpl.Builder parentTableBuilder =
PTableImpl.builderWithColumns(parentTableRef.getTable(),
getColumnsToClone(parentTableRef.getTable()))
- .setIndexes(newIndexes == null ? Collections.emptyList() : newIndexes);
+ .setIndexes(newIndexes);
if (tableTimeStamp != HConstants.LATEST_TIMESTAMP) {
parentTableBuilder.setTimeStamp(tableTimeStamp);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
index e895505..44373a2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
@@ -679,7 +679,7 @@ public class PTableImpl implements PTable {
Collections.sort(sortedColumns, new Comparator<PColumn>() {
@Override
public int compare(PColumn o1, PColumn o2) {
- return Integer.valueOf(o1.getPosition()).compareTo(o2.getPosition());
+ return Integer.compare(o1.getPosition(), o2.getPosition());
}
});
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAllocation.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAllocation.java
index af87e56..e24c2ad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAllocation.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SequenceAllocation.java
@@ -17,6 +17,8 @@
*/
package org.apache.phoenix.schema;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
/**
* A SequenceKey and the number of slots requested to be allocated for the sequence.
* It binds these two together to allow operations such as sorting
@@ -53,6 +55,8 @@ public class SequenceAllocation implements Comparable<SequenceAllocation> {
}
@Override
+ @SuppressWarnings(value="EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS",
+ justification="Checked in called function")
public boolean equals(Object obj) {
return sequenceKey.equals(obj);
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfo.java
index 2ae399e..6d5e2a5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/GuidePostsInfo.java
@@ -26,6 +26,9 @@ import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.SizedUtil;
import org.apache.phoenix.thirdparty.com.google.common.primitives.Longs;
+
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
/**
* A class that holds the guidePosts of a region and also allows combining the
* guidePosts of different regions when the GuidePostsInfo is formed for a table.
@@ -136,6 +139,8 @@ public class GuidePostsInfo {
return estimatedSize;
}
+ @SuppressWarnings(value="EC_ARRAY_AND_NONARRAY",
+ justification="ImmutableBytesWritable DOES implement equals(byte])")
public boolean isEmptyGuidePost() {
return guidePosts.equals(EMPTY_GUIDEPOST_KEY) && guidePostsCount == 0
&& byteCounts.length == 1 && gpTimestamps.length == 1;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/UpdateStatisticsTool.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/UpdateStatisticsTool.java
index 9aff6ac..1c8da96 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/UpdateStatisticsTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/UpdateStatisticsTool.java
@@ -54,6 +54,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
+
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import static org.apache.phoenix.query.QueryServices.IS_NAMESPACE_MAPPING_ENABLED;
@@ -116,7 +118,8 @@ public class UpdateStatisticsTool extends Configured implements Tool {
Admin admin = conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
boolean namespaceMapping = getConf().getBoolean(IS_NAMESPACE_MAPPING_ENABLED,
DEFAULT_IS_NAMESPACE_MAPPING_ENABLED);
- String physicalTableName = SchemaUtil.getPhysicalTableName(tableName.getBytes(),
+ String physicalTableName = SchemaUtil.getPhysicalTableName(
+ tableName.getBytes(StandardCharsets.UTF_8),
namespaceMapping).getNameAsString();
admin.snapshot(snapshotName, TableName.valueOf(physicalTableName));
LOGGER.info("Successfully created snapshot " + snapshotName + " for " + physicalTableName);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/task/Task.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/task/Task.java
index 2adf5f5..6a742e2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/task/Task.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/task/Task.java
@@ -54,6 +54,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
+@SuppressWarnings(value="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
+ justification="Not possible to avoid")
public class Task {
public static final Logger LOGGER = LoggerFactory.getLogger(Task.class);
private static void mutateSystemTaskTable(PhoenixConnection conn, PreparedStatement stmt, boolean accessCheckEnabled)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaSynthesisProcessor.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaSynthesisProcessor.java
index 7fe13bb..761621a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaSynthesisProcessor.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaSynthesisProcessor.java
@@ -36,8 +36,10 @@ import org.apache.phoenix.schema.SortOrder;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -208,7 +210,8 @@ public class SchemaSynthesisProcessor implements SchemaProcessor {
private List<String> getQueriesFromFile(String ddlFile) throws IOException {
StringBuilder sb = new StringBuilder();
File file = new File(ddlFile);
- BufferedReader br = new BufferedReader(new FileReader(file));
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file), StandardCharsets.UTF_8));
String st;
while ((st = br.readLine()) != null) {
sb.append(st).append("\n");
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaTool.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaTool.java
index c0e29e2..f9bbd36 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaTool.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/tool/SchemaTool.java
@@ -36,6 +36,8 @@ import org.apache.hadoop.util.ToolRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
public class SchemaTool extends Configured implements Tool {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaTool.class);
@@ -98,6 +100,8 @@ public class SchemaTool extends Configured implements Tool {
}
}
+ @SuppressWarnings(value="NP_NULL_ON_SOME_PATH",
+ justification="null path call calls System.exit()")
private CommandLine parseOptions(String[] args) {
final Options options = getOptions();
CommandLineParser parser = new DefaultParser(false, false);
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataType.java
index 12e8383..497c90f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataType.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataType.java
@@ -37,6 +37,8 @@ import org.apache.phoenix.util.ByteUtil;
import org.apache.phoenix.util.SchemaUtil;
import org.apache.phoenix.util.TrustedByteArrayOutputStream;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
import org.apache.phoenix.thirdparty.com.google.common.base.Objects;
import org.apache.phoenix.thirdparty.com.google.common.base.Preconditions;
@@ -310,6 +312,8 @@ public abstract class PArrayDataType<T> extends PDataType<T> {
return true;
}
+ @SuppressWarnings(value="RC_REF_COMPARISON",
+ justification="PDataTypes are expected to be singletons")
private void coerceBytes(ImmutableBytesWritable ptr, Object value, PDataType actualType, Integer maxLength,
Integer scale, Integer desiredMaxLength, Integer desiredScale, PDataType desiredType,
SortOrder actualSortOrder, SortOrder desiredSortOrder,
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataTypeEncoder.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataTypeEncoder.java
index 7467981..da1a42b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataTypeEncoder.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PArrayDataTypeEncoder.java
@@ -207,7 +207,7 @@ public class PArrayDataTypeEncoder implements ColumnValueEncoder {
} else {
// count the bytes written to serialize nulls
if (nulls > 0) {
- cellSize += (1 + Math.ceil(nulls / 255));
+ cellSize += (1 + Math.ceil(nulls / 255.0));
nulls = 0;
}
maxOffset = cellSize;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
index 3763c5f..5fa706a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
@@ -178,9 +178,6 @@ public abstract class PDataType<T> implements DataType<T>, Comparable<PDataType<
rhsConverted = ((PArrayDataType)this).toBytes(o, PArrayDataType.arrayBaseType(this), lhsSortOrder, PArrayDataType.isRowKeyOrderOptimized(this, lhsSortOrder, lhs, lhsOffset, lhsLength));
} else {
rhsConverted = this.toBytes(o);
- if (rhsSortOrder == SortOrder.DESC) {
- rhsSortOrder = SortOrder.ASC;
- }
if (lhsSortOrder == SortOrder.DESC) {
lhs = SortOrder.invert(lhs, lhsOffset, new byte[lhsLength], 0, lhsLength);
lhsOffset = 0;
@@ -199,9 +196,6 @@ public abstract class PDataType<T> implements DataType<T>, Comparable<PDataType<
lhsConverted = ((PArrayDataType)rhsType).toBytes(o, PArrayDataType.arrayBaseType(rhsType), rhsSortOrder, PArrayDataType.isRowKeyOrderOptimized(rhsType, rhsSortOrder, rhs, rhsOffset, rhsLength));
} else {
lhsConverted = rhsType.toBytes(o);
- if (lhsSortOrder == SortOrder.DESC) {
- lhsSortOrder = SortOrder.ASC;
- }
if (rhsSortOrder == SortOrder.DESC) {
rhs = SortOrder.invert(rhs, rhsOffset, new byte[rhsLength], 0, rhsLength);
}
@@ -312,7 +306,7 @@ public abstract class PDataType<T> implements DataType<T>, Comparable<PDataType<
@Override
public boolean equals(Object o) {
- // PDataType's are expected to be singletons.
+ // PDataTypes are expected to be singletons.
// TODO: this doesn't jive with HBase's DataType
if (o == null) return false;
return getClass() == o.getClass();
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDecimal.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDecimal.java
index fe8d306..a0480b5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDecimal.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDecimal.java
@@ -335,9 +335,8 @@ public class PDecimal extends PRealNumber<BigDecimal> {
maxLength = v[0];
scale = v[1];
}
- if (desiredMaxLength != null && desiredScale != null && maxLength != null && scale != null &&
- ((desiredScale == null && desiredMaxLength < maxLength) ||
- (desiredMaxLength - desiredScale) < (maxLength - scale))) {
+ if (desiredMaxLength != null && desiredScale != null && maxLength != null && scale != null
+ && ((desiredMaxLength - desiredScale) < (maxLength - scale))) {
return false;
}
return true;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
index 7e8f960..73f3c67 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
@@ -172,7 +172,7 @@ public class PhoenixArray implements Array,SQLCloseable {
}
private void boundaryCheck(long index, int count, Object[] arr) {
- if ((--index) + count > arr.length) {
+ if (index - 1 + count > arr.length) {
throw new IllegalArgumentException("The array index is out of range of the total number of elements in the array " + arr.length);
}
}
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/trace/TracingUtils.java b/phoenix-core/src/main/java/org/apache/phoenix/trace/TracingUtils.java
index 8bd918e..47409e0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/TracingUtils.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/TracingUtils.java
@@ -17,6 +17,8 @@
*/
package org.apache.phoenix.trace;
+import java.nio.charset.StandardCharsets;
+
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.htrace.Span;
@@ -34,11 +36,13 @@ public class TracingUtils {
public static final String METRICS_MARKER_CONTEXT = "marker";
public static void addAnnotation(Span span, String message, int value) {
- span.addKVAnnotation(message.getBytes(), Bytes.toBytes(Integer.toString(value)));
+ span.addKVAnnotation(message.getBytes(StandardCharsets.UTF_8),
+ Bytes.toBytes(Integer.toString(value)));
}
public static Pair<String, String> readAnnotation(byte[] key, byte[] value) {
- return new Pair<String, String>(new String(key), Bytes.toString(value));
+ return new Pair<String, String>(new String(key, StandardCharsets.UTF_8),
+ Bytes.toString(value));
}
/**
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/NullSpan.java b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/NullSpan.java
index b4f70b9..afde492 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/NullSpan.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/NullSpan.java
@@ -31,7 +31,7 @@ import org.apache.phoenix.util.StringUtil;
*/
public class NullSpan implements Span {
- public static Span INSTANCE = new NullSpan();
+ public static final Span INSTANCE = new NullSpan();
/**
* Private constructor to limit garbage
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
index e373ed3..eea838d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ColumnInfo.java
@@ -12,6 +12,7 @@ package org.apache.phoenix.util;
import java.sql.Types;
import java.util.List;
+import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -110,8 +111,8 @@ public class ColumnInfo {
ColumnInfo that = (ColumnInfo) o;
if (sqlType != that.sqlType) return false;
- if (precision != that.precision) return false;
- if (scale != that.scale) return false;
+ if (!Objects.equals(precision, that.precision)) return false;
+ if (!Objects.equals(scale, that.scale)) return false;
if (!columnName.equals(that.columnName)) return false;
return true;
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
index 1074b0b..4fc8430 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
@@ -29,6 +29,7 @@ import static org.apache.phoenix.util.PhoenixRuntime.getTable;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -240,7 +241,7 @@ public class IndexUtil {
public static byte[] getLocalIndexColumnFamily(byte[] dataColumnFamilyBytes) {
String dataCF = Bytes.toString(dataColumnFamilyBytes);
- return getLocalIndexColumnFamily(dataCF).getBytes();
+ return getLocalIndexColumnFamily(dataCF).getBytes(StandardCharsets.UTF_8);
}
public static PColumn getDataColumn(PTable dataTable, String indexColumnName) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
index 3f14a8e..742d81d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
@@ -22,6 +22,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.FAMILY_NAME_INDEX;
import static org.apache.phoenix.util.SchemaUtil.getVarChars;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.*;
@@ -1029,7 +1030,8 @@ public class MetaDataUtil {
family.getPColumnForColumnNameBytes(rowKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX]);
} else if (pkCount > COLUMN_NAME_INDEX
&& rowKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX].length > 0) {
- col = table.getPKColumn(new String(rowKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX]));
+ col = table.getPKColumn(new String(
+ rowKeyMetaData[PhoenixDatabaseMetaData.COLUMN_NAME_INDEX], StandardCharsets.UTF_8));
}
return col;
}
@@ -1042,7 +1044,6 @@ public class MetaDataUtil {
try {
connection.setAutoCommit(true);
Set<String> physicalTablesSet = new HashSet<>();
- Set<String> columnFamilies = new HashSet<>();
physicalTablesSet.add(table.getPhysicalName().getString());
for(byte[] physicalTableName:physicalTableNames) {
physicalTablesSet.add(Bytes.toString(physicalTableName));
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
index 1f15603..e7e2aa1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
@@ -26,6 +26,7 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
@@ -179,7 +180,7 @@ public class PhoenixMRJobUtil {
BufferedReader in = null;
StringBuilder response = null;
try {
- in = new BufferedReader(new InputStreamReader(is));
+ in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
String inputLine;
response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
index df46896..0a25880 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
@@ -22,9 +22,11 @@ import static org.apache.phoenix.thirdparty.com.google.common.base.Preconditions
import static org.apache.phoenix.schema.types.PDataType.ARRAY_TYPE_SUFFIX;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@@ -32,6 +34,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
@@ -54,6 +57,7 @@ import org.apache.phoenix.thirdparty.org.apache.commons.cli.HelpFormatter;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Option;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.Options;
import org.apache.phoenix.thirdparty.org.apache.commons.cli.ParseException;
+
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
@@ -212,7 +216,7 @@ public class PhoenixRuntime {
* All Phoenix specific connection properties
* TODO: use enum instead
*/
- public final static String[] CONNECTION_PROPERTIES = {
+ private final static String[] CONNECTION_PROPERTIES = {
CURRENT_SCN_ATTRIB,
TENANT_ID_ATTRIB,
UPSERT_BATCH_SIZE_ATTRIB,
@@ -298,7 +302,9 @@ public class PhoenixRuntime {
} else {
for (String inputFile : execCmd.getInputFiles()) {
if (inputFile.endsWith(SQL_FILE_EXT)) {
- PhoenixRuntime.executeStatements(conn, new FileReader(inputFile), Collections.emptyList());
+ PhoenixRuntime.executeStatements(conn, new InputStreamReader(
+ new FileInputStream(inputFile), StandardCharsets.UTF_8),
+ Collections.emptyList());
} else if (inputFile.endsWith(CSV_FILE_EXT)) {
String tableName = execCmd.getTableName();
@@ -335,6 +341,10 @@ public class PhoenixRuntime {
private PhoenixRuntime() {
}
+ public static final String[] getConnectionProperties() {
+ return Arrays.copyOf(CONNECTION_PROPERTIES, CONNECTION_PROPERTIES.length);
+ }
+
/**
* Runs a series of semicolon-terminated SQL statements using the connection provided, returning
* the number of SQL statements executed. Note that if the connection has specified an SCN through
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
index 5f9f13b..5c7816e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/QueryUtil.java
@@ -220,7 +220,7 @@ public final class QueryUtil {
new Function<String, String>() {
@Nullable
@Override
- public String apply(@Nullable String columnName) {
+ public String apply(String columnName) {
return getEscapedFullColumnName(columnName);
}
})),
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
index 46469bd..4254b5f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
@@ -29,6 +29,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES
import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE;
import static org.apache.phoenix.query.QueryConstants.SEPARATOR_BYTE_ARRAY;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
@@ -37,6 +38,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -144,8 +146,8 @@ public class SchemaUtil {
// See PHOENIX-4424
public static final String SCHEMA_FOR_DEFAULT_NAMESPACE = "default";
public static final String HBASE_NAMESPACE = "hbase";
- public static final List<String> NOT_ALLOWED_SCHEMA_LIST = Arrays.asList(SCHEMA_FOR_DEFAULT_NAMESPACE,
- HBASE_NAMESPACE);
+ public static final List<String> NOT_ALLOWED_SCHEMA_LIST = Collections.unmodifiableList(
+ Arrays.asList(SCHEMA_FOR_DEFAULT_NAMESPACE, HBASE_NAMESPACE));
/**
* May not be instantiated
@@ -1136,7 +1138,8 @@ public class SchemaUtil {
public static byte[] getParentTableNameFromIndexTable(byte[] physicalTableName, String indexPrefix) {
String tableName = Bytes.toString(physicalTableName);
- return getParentTableNameFromIndexTable(tableName, indexPrefix).getBytes();
+ return getParentTableNameFromIndexTable(tableName, indexPrefix)
+ .getBytes(StandardCharsets.UTF_8);
}
public static String getParentTableNameFromIndexTable(String physicalTableName, String indexPrefix) {
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java
index c642f36..5d1cad2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/StringUtil.java
@@ -41,13 +41,21 @@ public class StringUtil {
public final static char SINGLE_CHAR_LIKE = '_';
public final static char MULTI_CHAR_WILDCARD = '*';
public final static char MULTI_CHAR_LIKE = '%';
- public final static String[] LIKE_ESCAPE_SEQS = new String[]{"\\"+SINGLE_CHAR_LIKE, "\\"+MULTI_CHAR_LIKE};
- public final static String[] LIKE_UNESCAPED_SEQS = new String[]{""+SINGLE_CHAR_LIKE, ""+MULTI_CHAR_LIKE};
+ private final static String[] LIKE_ESCAPE_SEQS = new String[]{"\\"+SINGLE_CHAR_LIKE, "\\"+MULTI_CHAR_LIKE};
+ private final static String[] LIKE_UNESCAPED_SEQS = new String[]{""+SINGLE_CHAR_LIKE, ""+MULTI_CHAR_LIKE};
private StringUtil() {
}
+ public static final String[] getLikeEscapeSeqs() {
+ return Arrays.copyOf(LIKE_ESCAPE_SEQS, LIKE_ESCAPE_SEQS.length);
+ }
+
+ public static final String[] getLikeUnescapedSeqs() {
+ return Arrays.copyOf(LIKE_UNESCAPED_SEQS, LIKE_UNESCAPED_SEQS.length);
+ }
+
/** Replace instances of character ch in String value with String replacement */
public static String replaceChar(String value, char ch, CharSequence replacement) {
if (value == null)
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index 932652f..9bc25e1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -59,6 +59,7 @@ import static org.apache.phoenix.query.QueryConstants.BASE_TABLE_BASE_COLUMN_COU
import static org.apache.phoenix.query.QueryConstants.DIVERGED_VIEW_BASE_COLUMN_COUNT;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.Date;
@@ -149,6 +150,10 @@ import org.apache.phoenix.thirdparty.com.google.common.base.Objects;
import org.apache.phoenix.thirdparty.com.google.common.collect.Lists;
import org.apache.phoenix.thirdparty.com.google.common.collect.Sets;
+import edu.umd.cs.findbugs.annotations.SuppressWarnings;
+
+@SuppressWarnings(value = "SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING",
+ justification="Not possible to avoid")
public class UpgradeUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(UpgradeUtil.class);
private static final byte[] SEQ_PREFIX_BYTES = ByteUtil.concat(QueryConstants.SEPARATOR_BYTE_ARRAY, Bytes.toBytes("_SEQ_"));
@@ -159,7 +164,7 @@ public class UpgradeUtil {
* of this attribute overrides a true value for {@value QueryServices#AUTO_UPGRADE_ENABLED}.
*/
private static final String DO_NOT_UPGRADE = "DoNotUpgrade";
- public static String UPSERT_BASE_COLUMN_COUNT_IN_HEADER_ROW = "UPSERT "
+ public static final String UPSERT_BASE_COLUMN_COUNT_IN_HEADER_ROW = "UPSERT "
+ "INTO SYSTEM.CATALOG "
+ "(TENANT_ID, TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, COLUMN_FAMILY, BASE_COLUMN_COUNT) "
+ "VALUES (?, ?, ?, ?, ?, ?) ";
@@ -172,7 +177,7 @@ public class UpgradeUtil {
UPDATE_CACHE_FREQUENCY +
") VALUES (?, ?, ?, ?)";
- public static String SELECT_BASE_COLUMN_COUNT_FROM_HEADER_ROW = "SELECT "
+ public static final String SELECT_BASE_COLUMN_COUNT_FROM_HEADER_ROW = "SELECT "
+ "BASE_COLUMN_COUNT "
+ "FROM \"SYSTEM\".CATALOG "
+ "WHERE "
@@ -2110,8 +2115,9 @@ public class UpgradeUtil {
String destTableName, ReadOnlyProps props, Long ts, String phoenixTableName, PTableType pTableType,PName tenantId)
throws SnapshotCreationException, IllegalArgumentException, IOException, InterruptedException,
SQLException {
- if (!SchemaUtil.isNamespaceMappingEnabled(pTableType,
- props)) { throw new IllegalArgumentException(SchemaUtil.isSystemTable(srcTableName.getBytes())
+ if (!SchemaUtil.isNamespaceMappingEnabled(pTableType, props)) {
+ throw new IllegalArgumentException(
+ SchemaUtil.isSystemTable(srcTableName.getBytes(StandardCharsets.UTF_8))
? "For system table " + QueryServices.IS_SYSTEM_TABLE_MAPPED_TO_NAMESPACE
+ " also needs to be enabled along with " + QueryServices.IS_NAMESPACE_MAPPING_ENABLED
: QueryServices.IS_NAMESPACE_MAPPING_ENABLED + " is not enabled"); }
@@ -2226,8 +2232,9 @@ public class UpgradeUtil {
byte[] tenantId = conn.getTenantId() != null ?
conn.getTenantId().getBytes() : null;
ViewUtil.findAllRelatives(sysCatOrSysChildLinkTable, tenantId,
- schemaName.getBytes(),
- tableName.getBytes(), LinkType.CHILD_TABLE, childViewsResult);
+ schemaName.getBytes(StandardCharsets.UTF_8),
+ tableName.getBytes(StandardCharsets.UTF_8), LinkType.CHILD_TABLE,
+ childViewsResult);
break;
} catch (TableNotFoundException ex) {
// try again with SYSTEM.CATALOG in case the schema is old
@@ -2278,7 +2285,7 @@ public class UpgradeUtil {
index.getName(), srcTableName));
destTableName = Bytes
.toString(MetaDataUtil.getLocalIndexPhysicalName(
- newPhysicalTablename.getBytes()));
+ newPhysicalTablename.getBytes(StandardCharsets.UTF_8)));
// update parent_table property in local index table descriptor
conn.createStatement()
.execute(String.format("ALTER TABLE %s set " +
@@ -2289,7 +2296,7 @@ public class UpgradeUtil {
index.getName(), srcTableName));
destTableName = Bytes
.toString(MetaDataUtil.getViewIndexPhysicalName(
- newPhysicalTablename.getBytes()));
+ newPhysicalTablename.getBytes(StandardCharsets.UTF_8)));
} else {
LOGGER.info(String.format("Global index '%s' found with physical hbase table name ''..",
index.getName(), srcTableName));
diff --git a/pom.xml b/pom.xml
index d71840a..117daad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -216,6 +216,7 @@
<configuration>
<effort>Max</effort>
<maxHeap>2048</maxHeap>
+ <excludeFilterFile>${top.dir}/src/main/config/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
@@ -599,6 +600,9 @@
<!-- Argparse is bundled to work around system Python version
issues, compatibile with ALv2 -->
<exclude>bin/argparse-1.4.0/argparse.py</exclude>
+ <!-- tmp files -->
+ <exclude>dev/work/**</exclude>
+ <exclude>dev/artifacts/**</exclude>
</excludes>
</configuration>
</plugin>
diff --git a/src/main/config/spotbugs/spotbugs-exclude.xml b/src/main/config/spotbugs/spotbugs-exclude.xml
new file mode 100644
index 0000000..76104b1
--- /dev/null
+++ b/src/main/config/spotbugs/spotbugs-exclude.xml
@@ -0,0 +1,30 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<FindBugsFilter>
+ <Match>
+ <Class name="~org\.apache\.phoenix\.coprocessor\.generated\..*" />
+ </Match>
+ <Match>
+ <!-- Guava annotates some interfaces with @Null for some unfathomable reason -->
+ <BugPattern name="NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE" />
+ </Match>
+ <Match>
+ <!-- We cannot avoid hand-built SQL statements when manipulating SYSTEM.% tables -->
+ <BugPattern name="SQL_PREPARED_STATEMENT_GENERATED_FROM_NONCONSTANT_STRING" />
+ </Match>
+</FindBugsFilter>
\ No newline at end of file