From c8d3bc5254f58759cf95053c7a22ff21313de949 Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Tue, 21 Sep 2021 15:16:54 +0200 Subject: [PATCH 1/2] PHOENIX-6557 Fix code problems flagged by SpotBugs as High priority --- .../phoenix/cache/aggcache/SpillManager.java | 2 +- .../phoenix/compile/ExpressionCompiler.java | 3 +- .../apache/phoenix/compile/JoinCompiler.java | 1 - .../compile/OrderPreservingTracker.java | 3 +- .../compile/ServerBuildIndexCompiler.java | 2 +- .../phoenix/compile/SubselectRewriter.java | 3 +- .../compile/TupleProjectionCompiler.java | 2 +- .../coprocessor/MetaDataEndpointImpl.java | 22 +++++++++----- .../coprocessor/PhoenixAccessController.java | 2 +- .../apache/phoenix/execute/BaseQueryPlan.java | 4 ++- .../apache/phoenix/execute/HashJoinPlan.java | 4 ++- .../phoenix/expression/LikeExpression.java | 10 ++++++- .../expression/ProjectedColumnExpression.java | 2 +- .../BaseDecimalStddevAggregator.java | 3 +- .../FirstLastValueServerAggregator.java | 5 ++-- .../function/ArrayFillFunction.java | 2 +- .../expression/util/regex/JONIPattern.java | 3 +- .../TrackingParallelWriterIndexCommitter.java | 2 +- .../phoenix/index/PhoenixIndexCodec.java | 2 +- .../NonAggregateRegionScannerFactory.java | 2 +- .../phoenix/jdbc/PhoenixConnection.java | 7 +++-- .../jdbc/PhoenixPreparedStatement.java | 5 ---- .../phoenix/mapreduce/CsvBulkImportUtil.java | 8 +++-- .../mapreduce/MultiHfileOutputFormat.java | 8 ++++- .../phoenix/mapreduce/OrphanViewTool.java | 16 +++++++--- .../phoenix/mapreduce/PhoenixInputFormat.java | 2 +- .../PhoenixServerBuildIndexInputFormat.java | 10 +++---- .../bulkload/TargetTableRefFunctions.java | 10 +++---- .../mapreduce/index/IndexScrutinyMapper.java | 2 +- .../index/IndexScrutinyTableOutput.java | 2 +- .../mapreduce/index/IndexScrutinyTool.java | 1 - .../phoenix/mapreduce/index/IndexTool.java | 3 +- .../mapreduce/index/IndexUpgradeTool.java | 4 ++- .../IndexVerificationOutputRepository.java | 2 +- .../IndexVerificationResultRepository.java | 12 ++++---- .../index/PhoenixIndexImportDirectMapper.java | 6 ++-- .../PhoenixIndexImportDirectReducer.java | 2 +- .../index/PhoenixIndexPartialBuildMapper.java | 6 ++-- .../index/PhoenixServerBuildIndexMapper.java | 7 +++-- .../automation/PhoenixMRJobSubmitter.java | 1 - .../util/DefaultMultiViewSplitStrategy.java | 2 +- .../util/PhoenixConfigurationUtil.java | 4 +-- .../phoenix/monitoring/CombinableMetric.java | 6 ++-- .../monitoring/CombinableMetricImpl.java | 2 +- .../monitoring/TableMetricsManager.java | 4 +++ .../org/apache/phoenix/optimize/Cost.java | 4 +-- .../phoenix/parse/ChangePermsStatement.java | 3 +- .../org/apache/phoenix/parse/PFunction.java | 5 ++-- .../query/ConnectionQueryServicesImpl.java | 14 +++++---- .../ConnectionlessQueryServicesImpl.java | 4 --- .../query/ITGuidePostsCacheFactory.java | 2 +- .../apache/phoenix/query/QueryConstants.java | 5 ++-- .../phoenix/query/QueryServicesOptions.java | 2 +- .../apache/phoenix/schema/MetaDataClient.java | 20 +++++++------ .../apache/phoenix/schema/PMetaDataImpl.java | 2 +- .../org/apache/phoenix/schema/PTableImpl.java | 2 +- .../phoenix/schema/SequenceAllocation.java | 4 +++ .../phoenix/schema/stats/GuidePostsInfo.java | 6 ++++ .../schema/stats/UpdateStatisticsTool.java | 5 +++- .../org/apache/phoenix/schema/task/Task.java | 4 +++ .../schema/tool/SchemaSynthesisProcessor.java | 6 +++- .../phoenix/schema/tool/SchemaTool.java | 4 +++ .../phoenix/schema/types/PArrayDataType.java | 4 +++ .../schema/types/PArrayDataTypeEncoder.java | 2 +- .../phoenix/schema/types/PDataType.java | 8 +---- .../apache/phoenix/schema/types/PDecimal.java | 5 ++-- .../phoenix/schema/types/PhoenixArray.java | 2 +- .../apache/phoenix/trace/TracingUtils.java | 8 +++-- .../apache/phoenix/trace/util/NullSpan.java | 2 +- .../org/apache/phoenix/util/ColumnInfo.java | 5 ++-- .../org/apache/phoenix/util/IndexUtil.java | 3 +- .../org/apache/phoenix/util/MetaDataUtil.java | 7 +++-- .../apache/phoenix/util/PhoenixMRJobUtil.java | 3 +- .../apache/phoenix/util/PhoenixRuntime.java | 15 ++++++++-- .../org/apache/phoenix/util/QueryUtil.java | 2 +- .../org/apache/phoenix/util/SchemaUtil.java | 9 ++++-- .../org/apache/phoenix/util/StringUtil.java | 12 ++++++-- .../org/apache/phoenix/util/UpgradeUtil.java | 23 +++++++++----- pom.xml | 4 +++ src/main/config/spotbugs/spotbugs-exclude.xml | 30 +++++++++++++++++++ 80 files changed, 296 insertions(+), 151 deletions(-) create mode 100644 src/main/config/spotbugs/spotbugs-exclude.xml 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 e5d3717d5f9..a4bca6620f0 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 CacheEntry toCacheEntry(byte[] byte // 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 85c5553fc68..c52316b97be 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 @@ 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 Expression visitLeave(LikeParseNode node, List children) thro 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 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 d2a317544b3..bf383878fdc 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 @@ private static ParseNode combine(List nodes) { } private boolean isWildCardSelectForTable(List 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 80a0f423c7c..2701a48304c 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 int compare(Info o1, Info o2) { 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 007bb233da7..27e3585c422 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 MutationPlan compile(PTable index) throws SQLException { .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 a7d6dab5a66..93dadae7505 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 @@ private SelectStatement flatten(SelectStatement select, SelectStatement subselec 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 716123ca052..9a0b5b7703e 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 static PTable createProjectedTable(SelectStatement select, StatementConte 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 b4319ad9248..c69d8ccc4e0 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.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 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT // 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 @@ private PTable getTable(RegionScanner scanner, long clientTimeStamp, long tableT 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 @@ private static void getSchemaTableNames(Mutation row, byte[][] schemaTableNames) 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 @@ public void createTable(RpcController controller, CreateTableRequest request, // 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 e15ac43ba0b..c6f49a52062 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 String authString(String user, TableName table, Set actions) { 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 7ec5da84f31..05fb9244a9d 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 @@ 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 final ResultIterator iterator(final Map ca 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 c1a3b1da464..25d9fb3818e 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.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 ServerCache execute(HashJoinPlan parent) throws SQLException { 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 e68bff0fc02..6386a2372d1 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 52db52c08be..21eb2fe359b 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.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 38c30600348..0583f3550ca 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 boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { } 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 f647c45a5e4..298877ed7cc 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 String toString() { + " 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 c8db7f9eb8b..996be3dda1b 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 boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { 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 0ac33aff0c9..44631d3273e 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 @@ -17,6 +17,7 @@ */ package org.apache.phoenix.expression.util.regex; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; @@ -52,7 +53,7 @@ public JONIPattern(String patternString, int flags) { 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 1b6661d26b8..d35c7a56b25 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 @@ private void throwFailureIfDone() throws SingleIndexWriteFailureException { 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 9570dc5451c..5fbce2c7421 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 2a541c0df84..a07b6a9d860 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 RegionScanner getRegionScanner(final Scan scan, final RegionScanner s) th } int clientVersion = ScanUtil.getClientVersion(scan); List 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 105f45b6999..7c3b8ccf02e 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 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 @@ private PhoenixConnection(ConnectionQueryServices services, String url, } // 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 @@ private static void checkScnAndBuildIndexAtEquality(Long scnParam, Long replayAt 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 59d8add4885..83d8d85a0e8 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 @@ private void setParameter(int parameterIndex, Object value) throws SQLException 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 21787b2aed3..f3141ed0d8d 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 static void configurePreUpsertProcessor(Configuration conf, } @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 @@ static Character getCharacter(Configuration conf, String confKey) { 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 7aec4ee2fd0..24cbb65c6fa 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.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.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 @@ private static Map createFamilyConfValueMap(Map c 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 @@ static void configurePartitioner(Job job, Set tablesStartKeys) 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 tablesStartKeys) throws IOException { @@ -493,6 +498,7 @@ private static void writePartitions(Configuration conf, Path partitionsPath, TreeSet sorted = new TreeSet(tablesStartKeys); TableRowkeyPair first = sorted.first(); + if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: " 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 563d69b3238..f16982269f0 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 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 @@ else if (!cmdLine.hasOption(IDENTIFY_ORPHAN_VIEWS_OPTION.getOpt())) { 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 @@ private void createSnapshot(PhoenixConnection phoenixConnection, long scn) 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 @@ private void readOrphanViews() throws Exception { 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 int run(String[] args) throws Exception { 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 be20cc653a3..c294fede6f5 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 @@ protected QueryPlan getQueryPlan(final JobContext context, final Configuration // 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 536f88925d1..1052b309285 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 @@ protected QueryPlan getQueryPlan(final JobContext context, final Configuration c 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 @@ protected QueryPlan getQueryPlan(final JobContext context, final Configuration c 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 @@ protected QueryPlan getQueryPlan(final JobContext context, final Configuration c } // 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 f42fedaa959..9985379e576 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 @@ */ public class TargetTableRefFunctions { - public static Function TO_JSON = new Function() { + public static final Function TO_JSON = new Function() { @Override public String apply(TargetTableRef input) { @@ -44,7 +44,7 @@ public String apply(TargetTableRef input) { } }; - public static Function FROM_JSON = new Function() { + public static final Function FROM_JSON = new Function() { @Override public TargetTableRef apply(String json) { @@ -57,7 +57,7 @@ public TargetTableRef apply(String json) { } }; - public static Function,String> NAMES_TO_JSON = new Function,String>() { + public static final Function,String> NAMES_TO_JSON = new Function,String>() { @Override public String apply(List input) { @@ -74,7 +74,7 @@ public String apply(List input) { } }; - public static Function,String> LOGICAL_NAMES_TO_JSON = new Function,String>() { + public static final Function,String> LOGICAL_NAMES_TO_JSON = new Function,String>() { @Override public String apply(List input) { @@ -91,7 +91,7 @@ public String apply(List input) { } }; - public static Function> NAMES_FROM_JSON = new Function>() { + public static final Function> NAMES_FROM_JSON = new Function>() { @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 79f090909d6..6f3ca2cb59f 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 @@ protected void setup(final Context context) throws IOException, InterruptedExcep 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 b2075dc2ad7..6a2aa905dd6 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 ed04865434f..1f775d6370c 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 Job createSubmittableJob(String schemaName, String indexTable, String dat // 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 fbb9b18ef6b..0738e59caca 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 @@ -117,6 +117,7 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; +import edu.umd.cs.findbugs.annotations.SuppressWarnings; /** * An MR job to populate the index table from the data table. * @@ -571,7 +572,7 @@ private Job configureJobForPartialBuild() throws Exception { 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 ba7d957acc3..f42d7056bc7 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.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 void prepareToolSetup() { 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 74038e898ce..a0cd037bddd 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 55b7d3bc8ab..9ff5ed0809c 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 eca3a9eda82..d4c9798004d 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 @@ protected void cleanup(Context context) throws IOException, InterruptedException } // 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 ab13729f54f..27249908419 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 @@ private void updateCounters(IndexTool.IndexVerifyType verifyType, 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 ca5d240730f..fd4651e0a4b 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 @@ protected void cleanup(Context context) throws IOException, InterruptedException } // 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 7a75cf62b5f..8cdcb6a7125 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 @@ protected void setup(final Context context) throws IOException, InterruptedExcep 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 @@ protected void map(NullWritable key, PhoenixServerBuildIndexDBWritable record, C @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 82959fce51d..93fa57c49f9 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 Set getJobsToSubmit(Map can 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 79808cad0f1..62e5150617a 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 List generateSplits(List views, */ 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 737c2ef1b57..f17510e68dd 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 static void setMultiViewQueryMoreSplitSize(Configuration configuration, f 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 getSelectColumnMetadataList(final Configuration configuration) throws SQLException { @@ -493,7 +493,7 @@ public static List getSelectColumnMetadataList(final Configuration c 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 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 103fd142d1b..07cd25dfcca 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 bd22418ddb1..40cb5166c3e 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 4688137722a..f3c626b827b 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.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 b83f3548407..788e4b9aa36 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 @@ */ public class Cost implements Comparable { /** 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 String toString() { }; /** 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 0eae26f7f7c..b49183d3a3b 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.jdbc.PhoenixStatement; import org.apache.phoenix.util.SchemaUtil; +import java.nio.charset.StandardCharsets; import java.util.Arrays; /** @@ -44,7 +45,7 @@ public ChangePermsStatement(String permsString, boolean isSchemaName, // 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 a5263adf69e..72348ad4129 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,11 @@ public PFunction(PName tenantId, String functionName, List arg 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 + + 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 +269,7 @@ public static PFunction createFromProto( 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 3810fc1a66a..f39db51a670 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 @@ -312,6 +312,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.thirdparty.com.google.common.collect.Sets; +import edu.umd.cs.findbugs.annotations.SuppressWarnings; + public class ConnectionQueryServicesImpl extends DelegateQueryServices implements ConnectionQueryServices { private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionQueryServicesImpl.class); @@ -379,7 +381,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 +1270,7 @@ private void checkAndRetry(RetriableOperation op) throws InterruptedException, T 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 +1278,7 @@ private void checkAndRetry(RetriableOperation op) throws InterruptedException, T + " completed within " + watch.elapsedMillis() + "ms " - + (numTries > 1 ? ("after trying " + numTries + (numTries > 1 ? "times." : "time.")) : "")); + + "after trying " + numTries + " times." ); } } } @@ -1694,7 +1696,7 @@ public GetVersionResponse call(MetaDataService instance) + getServerVersion(serverJarVersion)); } } - hasIndexWALCodec &= hasIndexWALCodec(serverJarVersion); + hasIndexWALCodec = hasIndexWALCodec && hasIndexWALCodec(serverJarVersion); if (minHBaseVersion > MetaDataUtil.decodeHBaseVersion(serverJarVersion)) { minHBaseVersion = MetaDataUtil.decodeHBaseVersion(serverJarVersion); } @@ -2279,7 +2281,9 @@ private void ensureViewIndexTableCreated(PTable table, long timestamp, boolean i 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 17562d61b65..ce2fb1b2ed2 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 void addSchema(PSchema schema) throws SQLException { @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 a22a65039af..61a91755c8c 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 @@ * Test Class Only used to verify in e2e tests */ public class ITGuidePostsCacheFactory implements GuidePostsCacheFactory { - public static ConcurrentHashMap map = + public static final ConcurrentHashMap 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 32b14dcd0fe..7002fbfd0dd 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 @@ 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 @@ enum JoinType {INNER, LEFT_OUTER} 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 e1c3303532c..930e5dc3c88 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 c85e220cad2..eb719f09d26 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.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.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 @@ private PTable createTableInternal(CreateTableStatement statement, byte[][] spli // 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 boolean isViewReferenced() { } 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 boolean isViewReferenced() { .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 boolean isViewReferenced() { .setIndexes(Collections.emptyList()) .setParentSchemaName((parent == null) ? null : parent.getSchemaName()) .setParentTableName((parent == null) ? null : parent.getTableName()) - .setPhysicalNames(physicalNames == null ? - ImmutableList.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 MutationState addColumn(PTable table, List origColumnDefs, 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 f172a0b6ed6..d43d2aa60c7 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 void removeTable(PName tenantId, String tableName, String parentTableName 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 e8955056e18..44373a26ca7 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 @@ private Builder initDerivedAttributes() throws SQLException { Collections.sort(sortedColumns, new Comparator() { @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 af87e56c84f..e24c2ad0e83 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 int hashCode() { } @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 2ae399e517f..a329567da9f 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 @@ -17,6 +17,7 @@ */ package org.apache.phoenix.schema.stats; + import java.util.Collections; import java.util.List; @@ -26,6 +27,9 @@ 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 +140,8 @@ public int getEstimatedSize() { 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 9aff6acc458..1c8da9606a5 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.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 @@ private void preJobTask() throws Exception { 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 2adf5f5a94c..6a742e210da 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.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 7fe13bbd5d1..5cfc1b70772 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,11 @@ import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; 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 +211,8 @@ private ListMultimap> getEffectiveProperties( private List 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 c0e29e2b811..f9bbd368077 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.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 @@ private void populateToolAttributes(String[] args) { } } + @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 12e8383bf27..497c90fdae4 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.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 boolean isSizeCompatible(ImmutableBytesWritable ptr, Object value, PDataT 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 74679816122..da1a42b44d7 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 static int getEstimatedByteSize(PTable table, int rowLength, } 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 3763c5f237f..5fa706a24fe 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 final int compareTo(byte[] lhs, int lhsOffset, int lhsLength, SortOrder l 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 final int compareTo(byte[] lhs, int lhsOffset, int lhsLength, SortOrder l 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 @@ protected static RuntimeException newIllegalDataException(Exception e) { @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 fe8d306f4a0..a0480b5ae82 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 boolean isSizeCompatible(ImmutableBytesWritable ptr, Object value, PDataT 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 7e8f9604976..73f3c67de0c 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 Object getArray(long index, int count) throws SQLException { } 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 8bd918e5c7d..47409e00439 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 readAnnotation(byte[] key, byte[] value) { - return new Pair(new String(key), Bytes.toString(value)); + return new Pair(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 b4f70b92c95..afde49297dd 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 @@ */ 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 e373ed3b379..eea838d571d 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 @@ 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 boolean equals(Object o) { 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 1074b0b349f..4fc8430806e 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 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 static String getLocalIndexColumnFamily(String dataColumnFamilyName) { 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 3f14a8eae2e..6d2a3d21ba7 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.util.SchemaUtil.getVarChars; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.sql.SQLException; import java.util.*; @@ -81,6 +82,8 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Iterables; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; +import edu.umd.cs.findbugs.annotations.SuppressWarnings; + public class MetaDataUtil { private static final Logger LOGGER = LoggerFactory.getLogger(MetaDataUtil.class); @@ -1029,7 +1032,8 @@ public static PColumn getColumn(int pkCount, byte[][] rowKeyMetaData, PTable tab 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 +1046,6 @@ public static void deleteFromStatsTable(PhoenixConnection connection, try { connection.setAutoCommit(true); Set physicalTablesSet = new HashSet<>(); - Set 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 1f156036028..e7e2aa150da 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.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 static String getTextContent(InputStream is) throws IOException { 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 df46896bd4a..bb9a0d8ee3c 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,12 @@ import static org.apache.phoenix.schema.types.PDataType.ARRAY_TYPE_SUFFIX; import java.io.File; +import java.io.FileInputStream; import java.io.FileReader; 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 +35,7 @@ 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 +58,7 @@ 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 +217,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 +303,9 @@ public static void main(String [] args) { } 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 +342,10 @@ public static void main(String [] args) { 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 5f9f13b7b13..5c7816ef3fc 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 static String constructUpsertStatement(String tableName, List col new Function() { @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 46469bdaa5e..4254b5f2e7d 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.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.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 SortOrder getSortOrder() { // See PHOENIX-4424 public static final String SCHEMA_FOR_DEFAULT_NAMESPACE = "default"; public static final String HBASE_NAMESPACE = "hbase"; - public static final List NOT_ALLOWED_SCHEMA_LIST = Arrays.asList(SCHEMA_FOR_DEFAULT_NAMESPACE, - HBASE_NAMESPACE); + public static final List NOT_ALLOWED_SCHEMA_LIST = Collections.unmodifiableList( + Arrays.asList(SCHEMA_FOR_DEFAULT_NAMESPACE, HBASE_NAMESPACE)); /** * May not be instantiated @@ -1136,7 +1138,8 @@ public static boolean isNamespaceMappingEnabled(PTableType type, ReadOnlyProps r 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 c642f369460..5d1cad2b581 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 932652f5e07..9bc25e13119 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.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.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 @@ private static void mapTableToNamespace(Admin admin, Table metatable, String src 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 static void upgradeTable(PhoenixConnection conn, String srcTable) throws 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 static void upgradeTable(PhoenixConnection conn, String srcTable) throws 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 static void upgradeTable(PhoenixConnection conn, String srcTable) throws 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 d71840a0ca1..117daad6cd3 100644 --- a/pom.xml +++ b/pom.xml @@ -216,6 +216,7 @@ Max 2048 + ${top.dir}/src/main/config/spotbugs/spotbugs-exclude.xml bin/argparse-1.4.0/argparse.py + + dev/work/** + dev/artifacts/** diff --git a/src/main/config/spotbugs/spotbugs-exclude.xml b/src/main/config/spotbugs/spotbugs-exclude.xml new file mode 100644 index 00000000000..76104b1a97b --- /dev/null +++ b/src/main/config/spotbugs/spotbugs-exclude.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file From ce24a2a2a75a6dafad371c497834ae45c576fbde Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Mon, 27 Sep 2021 14:05:17 +0200 Subject: [PATCH 2/2] cleanups suggested in review --- .../org/apache/phoenix/expression/util/regex/JONIPattern.java | 1 - .../org/apache/phoenix/mapreduce/MultiHfileOutputFormat.java | 1 - .../java/org/apache/phoenix/mapreduce/index/IndexTool.java | 1 - .../src/main/java/org/apache/phoenix/parse/PFunction.java | 3 ++- .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java | 2 -- .../java/org/apache/phoenix/schema/stats/GuidePostsInfo.java | 1 - .../apache/phoenix/schema/tool/SchemaSynthesisProcessor.java | 1 - .../src/main/java/org/apache/phoenix/util/MetaDataUtil.java | 2 -- .../src/main/java/org/apache/phoenix/util/PhoenixRuntime.java | 1 - 9 files changed, 2 insertions(+), 11 deletions(-) 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 44631d3273e..d9bb54deb87 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 @@ -17,7 +17,6 @@ */ package org.apache.phoenix.expression.util.regex; -import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; 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 24cbb65c6fa..3a9071e123f 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 @@ -498,7 +498,6 @@ private static void writePartitions(Configuration conf, Path partitionsPath, TreeSet sorted = new TreeSet(tablesStartKeys); TableRowkeyPair first = sorted.first(); - if (!first.getRowkey().equals(HConstants.EMPTY_BYTE_ARRAY)) { throw new IllegalArgumentException( "First region of table should have empty start key. Instead has: " 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 0738e59caca..34d8b1c1301 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 @@ -117,7 +117,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; -import edu.umd.cs.findbugs.annotations.SuppressWarnings; /** * An MR job to populate the index table from the data table. * 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 72348ad4129..f914fbae865 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,7 +101,8 @@ public PFunction(PName tenantId, String functionName, List arg this.returnType = PNameFactory.newName(returnType); this.functionKey = new PTableKey(this.tenantId, this.functionName.getString()); this.timeStamp = timeStamp; - 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) + 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 f39db51a670..3927c17f405 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 @@ -312,8 +312,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Maps; import org.apache.phoenix.thirdparty.com.google.common.collect.Sets; -import edu.umd.cs.findbugs.annotations.SuppressWarnings; - public class ConnectionQueryServicesImpl extends DelegateQueryServices implements ConnectionQueryServices { private static final Logger LOGGER = LoggerFactory.getLogger(ConnectionQueryServicesImpl.class); 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 a329567da9f..6d5e2a54805 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 @@ -17,7 +17,6 @@ */ package org.apache.phoenix.schema.stats; - import java.util.Collections; import java.util.List; 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 5cfc1b70772..761621a754a 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 @@ -37,7 +37,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; 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 6d2a3d21ba7..742d81df617 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 @@ -82,8 +82,6 @@ import org.apache.phoenix.thirdparty.com.google.common.collect.Iterables; import org.apache.phoenix.thirdparty.com.google.common.collect.Lists; -import edu.umd.cs.findbugs.annotations.SuppressWarnings; - public class MetaDataUtil { private static final Logger LOGGER = LoggerFactory.getLogger(MetaDataUtil.class); 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 bb9a0d8ee3c..0a258808c87 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 @@ -23,7 +23,6 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader;