diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java index 6f5051bb374..afc5ba00886 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerLoad.java @@ -235,7 +235,7 @@ public class ServerLoad { for (Coprocessor coprocessor : obtainServerLoadPB().getCoprocessorsList()) { coprocessSet.add(coprocessor.getName()); } - return coprocessSet.toArray(new String[0]); + return coprocessSet.toArray(new String[coprocessSet.size()]); } /** diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/Authorizations.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/Authorizations.java index a82d6d8b3f2..0cbd60e7aa1 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/Authorizations.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/security/visibility/Authorizations.java @@ -35,9 +35,7 @@ public class Authorizations { private List labels; public Authorizations(String... labels) { this.labels = new ArrayList(labels.length); - for (String label : labels) { - this.labels.add(label); - } + Collections.addAll(this.labels, labels); } public Authorizations(List labels) { diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java index 467c7fe0247..0b67b415601 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestKeyValue.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hbase; import java.io.IOException; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -228,9 +229,7 @@ public class TestKeyValue extends TestCase { new KeyValue(Bytes.toBytes("a,a,0"), fam, qf, 0, nb), }; // Add to set with bad comparator - for (int i = 0; i < keys.length; i++) { - set.add(keys[i]); - } + Collections.addAll(set, keys); // This will output the keys incorrectly. boolean assertion = false; int count = 0; @@ -245,9 +244,7 @@ public class TestKeyValue extends TestCase { assertTrue(assertion); // Make set with good comparator set = new TreeSet(new KeyValue.MetaComparator()); - for (int i = 0; i < keys.length; i++) { - set.add(keys[i]); - } + Collections.addAll(set, keys); count = 0; for (KeyValue k: set) { assertTrue(count++ == k.getTimestamp()); diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java index aa2850946b1..17d54937e07 100644 --- a/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java +++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/util/TestConcatenatedLists.java @@ -119,7 +119,7 @@ public class TestConcatenatedLists { assertEquals((last == -1), c.isEmpty()); assertEquals(last + 1, c.size()); assertTrue(c.containsAll(c)); - Long[] array = c.toArray(new Long[0]); + Long[] array = c.toArray(new Long[c.size()]); List all = new ArrayList(); Iterator iter = c.iterator(); for (Long i = 0L; i <= last; ++i) { diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/IndexBuilder.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/IndexBuilder.java index 79c6bbe0a10..6df345bfe67 100644 --- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/IndexBuilder.java +++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/mapreduce/IndexBuilder.java @@ -124,9 +124,7 @@ public class IndexBuilder { conf.set("index.tablename", tableName); conf.set("index.familyname", columnFamily); String[] fields = new String[args.length - 2]; - for(int i = 0; i < fields.length; i++) { - fields[i] = args[i + 2]; - } + System.arraycopy(args, 2, fields, 0, fields.length); conf.setStrings("index.fields", fields); Job job = new Job(conf, tableName); job.setJarByClass(IndexBuilder.class); diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/RollingBatchRestartRsAction.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/RollingBatchRestartRsAction.java index 7530383d163..4d0cc6b582a 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/RollingBatchRestartRsAction.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/chaos/actions/RollingBatchRestartRsAction.java @@ -127,7 +127,7 @@ public class RollingBatchRestartRsAction extends BatchRestartRsAction { for (int i = 0; i < 4; i++) { serverNames.add(ServerName.valueOf(i + ".example.org", i, i)); } - return serverNames.toArray(new ServerName [] {}); + return serverNames.toArray(new ServerName[serverNames.size()]); } @Override diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java index a1b51622834..f5e5506675a 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/test/IntegrationTestBigLinkedList.java @@ -401,8 +401,7 @@ public class IntegrationTestBigLinkedList extends IntegrationTestBase { private static void circularLeftShift(T[] first) { T ez = first[0]; - for (int i = 0; i < first.length - 1; i++) - first[i] = first[i + 1]; + System.arraycopy(first, 1, first, 0, first.length - 1); first[first.length - 1] = ez; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java index 3789148a7d8..820008db330 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/FileLink.java @@ -413,9 +413,7 @@ public class FileLink { assert this.locations == null : "Link locations already set"; this.locations = new Path[1 + alternativePaths.length]; this.locations[0] = originPath; - for (int i = 0; i < alternativePaths.length; i++) { - this.locations[i + 1] = alternativePaths[i]; - } + System.arraycopy(alternativePaths, 0, this.locations, 1, alternativePaths.length); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java index 3b59509f68c..527cdd63c7e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java @@ -171,8 +171,7 @@ public class SplitLogManager { if (logfiles == null || logfiles.length == 0) { LOG.info(hLogDir + " is empty dir, no logs to split"); } else { - for (FileStatus status : logfiles) - fileStatus.add(status); + Collections.addAll(fileStatus, logfiles); } } FileStatus[] a = new FileStatus[fileStatus.size()]; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java index 2c03f9ddae6..d8172782ac2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java @@ -898,9 +898,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer { String[] tables = conf.getStrings( "hbase.balancer.tablesOnMaster", DEFAULT_TABLES_ON_MASTER); if (tables != null) { - for (String table: tables) { - tablesOnMaster.add(table); - } + Collections.addAll(tablesOnMaster, tables); } this.rackManager = new RackManager(getConf()); regionFinder.setConf(conf); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java index 28d1002111a..06c341bb7ae 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java @@ -1174,11 +1174,8 @@ public class StochasticLoadBalancer extends BaseLoadBalancer { } // max cost is the case where every region replica is hosted together regardless of host int[] primariesOfRegions = new int[cluster.numRegions]; - for (int i = 0; i < cluster.regions.length; i++) { - // assume all regions are hosted by only one server - int primaryIndex = cluster.regionIndexToPrimaryIndex[i]; - primariesOfRegions[i] = primaryIndex; - } + System.arraycopy(cluster.regionIndexToPrimaryIndex, 0, primariesOfRegions, 0, + cluster.regions.length); Arrays.sort(primariesOfRegions); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java index 372115baa68..23b6e9b227d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java @@ -161,7 +161,7 @@ public class MetricsMBeanBase extends MetricsDynamicMBeanBase { LOG.info("new MBeanInfo"); this.extendedInfo = new MBeanInfo( this.getClass().getName(), - this.description, attributes.toArray( new MBeanAttributeInfo[0] ), + this.description, attributes.toArray(new MBeanAttributeInfo[attributes.size()]), parentInfo.getConstructors(), parentInfo.getOperations(), parentInfo.getNotifications() ); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeStoreFileManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeStoreFileManager.java index c297c56b724..3e1fd202364 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeStoreFileManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StripeStoreFileManager.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; @@ -913,9 +914,7 @@ public class StripeStoreFileManager if (this.state.stripeFiles.isEmpty()) return new ArrayList(); ArrayList result = new ArrayList(this.state.stripeEndRows.length + 2); result.add(OPEN_KEY); - for (int i = 0; i < this.state.stripeEndRows.length; ++i) { - result.add(this.state.stripeEndRows[i]); - } + Collections.addAll(result, this.state.stripeEndRows); result.add(OPEN_KEY); return result; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java index 56d8349c119..bae71fc415a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/FSHLog.java @@ -1221,7 +1221,7 @@ class FSHLog implements HLog, Syncable { void offer(final long sequence, final SyncFuture [] syncFutures, final int syncFutureCount) { // Set sequence first because the add to the queue will wake the thread if sleeping. this.sequence = sequence; - for (int i = 0; i < syncFutureCount; i++) this.syncFutures.add(syncFutures[i]); + this.syncFutures.addAll(Arrays.asList(syncFutures).subList(0, syncFutureCount)); } /** diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ChainWALEntryFilter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ChainWALEntryFilter.java index f701e94333d..05197b9a14c 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ChainWALEntryFilter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/ChainWALEntryFilter.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.replication; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.hadoop.classification.InterfaceAudience; @@ -43,9 +44,7 @@ public class ChainWALEntryFilter implements WALEntryFilter { // flatten the chains for (WALEntryFilter filter : filters) { if (filter instanceof ChainWALEntryFilter) { - for (WALEntryFilter f : ((ChainWALEntryFilter) filter).filters) { - rawFilters.add(f); - } + Collections.addAll(rawFilters, ((ChainWALEntryFilter) filter).filters); } else { rawFilters.add(filter); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java index 0bb1c708d4e..071f17162c2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/rest/RowSpec.java @@ -23,6 +23,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.TreeSet; @@ -270,9 +271,7 @@ public class RowSpec { this.row = startRow; this.endRow = endRow; if (columns != null) { - for (byte[] col: columns) { - this.columns.add(col); - } + Collections.addAll(this.columns, columns); } this.startTime = startTime; this.endTime = endTime; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/expression/NonLeafExpressionNode.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/expression/NonLeafExpressionNode.java index 03def941d43..2bf22685d39 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/expression/NonLeafExpressionNode.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/expression/NonLeafExpressionNode.java @@ -18,6 +18,7 @@ package org.apache.hadoop.hbase.security.visibility.expression; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.hadoop.classification.InterfaceAudience; @@ -46,9 +47,7 @@ public class NonLeafExpressionNode implements ExpressionNode { public NonLeafExpressionNode(Operator op, ExpressionNode... exps) { this.op = op; List expLst = new ArrayList(); - for (ExpressionNode exp : exps) { - expLst.add(exp); - } + Collections.addAll(expLst, exps); this.childExps = expLst; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CollectionBackedScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CollectionBackedScanner.java index 72751d8b7ac..2f4372938c1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CollectionBackedScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/CollectionBackedScanner.java @@ -68,9 +68,7 @@ public class CollectionBackedScanner extends NonReversedNonLazyKeyValueScanner { this.comparator = comparator; List tmp = new ArrayList(array.length); - for( int i = 0; i < array.length ; ++i) { - tmp.add(array[i]); - } + Collections.addAll(tmp, array); Collections.sort(tmp, comparator); data = tmp; init(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index 647c38f02c3..44621ca4b4e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -1298,7 +1298,7 @@ public class HBaseFsck extends Configured { "You may need to restore the previously sidelined hbase:meta"); return false; } - meta.batchMutate(puts.toArray(new Put[0])); + meta.batchMutate(puts.toArray(new Put[puts.size()])); HRegion.closeHRegion(meta); LOG.info("Success! hbase:meta table rebuilt."); LOG.info("Old hbase:meta is moved into " + backupDir); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MunkresAssignment.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MunkresAssignment.java index e39e9f65427..de8baaac2a1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MunkresAssignment.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MunkresAssignment.java @@ -129,9 +129,7 @@ public class MunkresAssignment { } } else { for (int r = 0; r < rows; r++) { - for (int c = 0; c < cols; c++) { - cost[r][c] = costMatrix[r][c]; - } + System.arraycopy(costMatrix[r], 0, cost[r], 0, cols); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java index a696d5f97ad..58dc14a45e0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java @@ -681,7 +681,7 @@ public class RegionSplitter { LinkedList check = Lists.newLinkedList(); check.add(table.getRegionLocation(start).getRegionInfo()); check.add(table.getRegionLocation(split).getRegionInfo()); - for (HRegionInfo hri : check.toArray(new HRegionInfo[] {})) { + for (HRegionInfo hri : check.toArray(new HRegionInfo[check.size()])) { byte[] sk = hri.getStartKey(); if (sk.length == 0) sk = splitAlgo.firstRow(); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java index 05ffe84a0c6..2441cf7b295 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java @@ -2074,9 +2074,7 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility { byte [] endKey = Bytes.toBytes("zzzzz"); byte [][] splitKeys = Bytes.split(startKey, endKey, numRegions - 3); byte [][] regionStartKeys = new byte[splitKeys.length+1][]; - for (int i=0;i3); byte [][] tmpSplitKeys = Bytes.split(startKey, endKey, numRegions - 3); byte [][] result = new byte[tmpSplitKeys.length+1][]; - for (int i=0;i result = new HashSet(ts.length); - for (int i = 0; i < ts.length; i++) { - result.add(ts[i]); - } + Collections.addAll(result, ts); int size = result.size(); assertTrue(size >= tables.length); for (int i = 0; i < tables.length && i < size; i++) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java index fa129f9e8df..6f39d3b904e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.apache.commons.logging.Log; @@ -193,9 +194,7 @@ public class TestSnapshotMetadata { // restore the snapshot into a cloned table and examine the output List familiesList = new ArrayList(); - for (byte[] family : families) { - familiesList.add(family); - } + Collections.addAll(familiesList, families); // Create a snapshot in which all families are empty SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, null, @@ -277,9 +276,7 @@ public class TestSnapshotMetadata { } familiesWithDataList.add(familyForUpdate); } else { - for (byte[] family : families) { - emptyFamiliesList.add(family); - } + Collections.addAll(emptyFamiliesList, families); } // take a "disabled" snapshot diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java index 4288d4e55f7..a44125df25b 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestInvocationRecordFilter.java @@ -87,33 +87,33 @@ public class TestInvocationRecordFilter { List expectedQualifiers = new ArrayList(); selectQualifiers.add(-1); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); selectQualifiers.clear(); selectQualifiers.add(0); expectedQualifiers.add(0); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); selectQualifiers.add(3); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); selectQualifiers.add(4); expectedQualifiers.add(4); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); selectQualifiers.add(5); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); selectQualifiers.add(8); expectedQualifiers.add(8); - verifyInvocationResults(selectQualifiers.toArray(new Integer[0]), - expectedQualifiers.toArray(new Integer[0])); + verifyInvocationResults(selectQualifiers.toArray(new Integer[selectQualifiers.size()]), + expectedQualifiers.toArray(new Integer[expectedQualifiers.size()])); } public void verifyInvocationResults(Integer[] selectQualifiers, diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java index d90c1d3588b..0685568d9ca 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java @@ -655,9 +655,7 @@ public class TestStripeCompactionPolicy { byte[][] keys = new byte[][] { KEY_A, KEY_B, KEY_C, KEY_D, KEY_E }; assert stripeCount <= keys.length + 1; List boundaries = new ArrayList(); - for (int i = 0; i < stripeCount - 1; ++i) { - boundaries.add(keys[i]); - } + boundaries.addAll(Arrays.asList(keys).subList(0, stripeCount - 1)); return boundaries; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestUser.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestUser.java index 389d40634ac..f85832e59e3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestUser.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestUser.java @@ -134,11 +134,13 @@ public class TestUser { final String username = "testuser"; final ImmutableSet singleGroups = ImmutableSet.of("group"); final Configuration conf = HBaseConfiguration.create(); - User user = User.createUserForTesting(conf, username, singleGroups.toArray(new String[]{})); + User user = User.createUserForTesting(conf, username, + singleGroups.toArray(new String[singleGroups.size()])); assertUserGroup(user, singleGroups); final ImmutableSet multiGroups = ImmutableSet.of("group", "group1", "group2"); - user = User.createUserForTesting(conf, username, multiGroups.toArray(new String[]{})); + user = User.createUserForTesting(conf, username, + multiGroups.toArray(new String[multiGroups.size()])); assertUserGroup(user, multiGroups); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java index 57108878a56..ce634029ad3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/LoadTestTool.java @@ -757,9 +757,7 @@ public class LoadTestTool extends AbstractHBaseTool { newArgs = new String[cmdLineArgs.length + 2]; newArgs[0] = "-" + LoadTestTool.OPT_TABLE_NAME; newArgs[1] = LoadTestTool.DEFAULT_TABLE_NAME; - for (int i = 0; i < cmdLineArgs.length; i++) { - newArgs[i + 2] = cmdLineArgs[i]; - } + System.arraycopy(cmdLineArgs, 0, newArgs, 2, cmdLineArgs.length); } else { newArgs = cmdLineArgs; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java index 71461bab62c..e2fa54d2c0c 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java @@ -693,8 +693,8 @@ public class TestHBaseFsck { } } Put put = new Put(metaKey); - ServerName sn = TEST_UTIL.getHBaseAdmin().getClusterStatus().getServers() - .toArray(new ServerName[0])[0]; + Collection var = TEST_UTIL.getHBaseAdmin().getClusterStatus().getServers(); + ServerName sn = var.toArray(new ServerName[var.size()])[0]; //add a location with replicaId as 2 (since we already have replicas with replicaid 0 and 1) MetaTableAccessor.addLocation(put, sn, sn.getStartcode(), 2); meta.put(put); diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java index fc3d9276ffb..b350d80f878 100644 --- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java +++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServerCmdLine.java @@ -173,7 +173,7 @@ public class TestThriftServerCmdLine { args.add("start"); thriftServer = new ThriftServer(TEST_UTIL.getConfiguration()); - startCmdLineThread(args.toArray(new String[0])); + startCmdLineThread(args.toArray(new String[args.size()])); // wait up to 10s for the server to start for (int i = 0; i < 100