HBASE-18983 update error-prone to 2.1.1

This commit is contained in:
Mike Drob 2017-10-11 11:36:41 -05:00
parent 2085958216
commit 3a0f59d031
14 changed files with 53 additions and 91 deletions

View File

@ -27,6 +27,7 @@ import java.io.IOException;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
@ -746,12 +747,12 @@ public class TestAsyncProcess {
puts.add(createPut(1, true)); puts.add(createPut(1, true));
for (int i = 0; i != controller.maxConcurrentTasksPerRegion; ++i) { for (int i = 0; i != controller.maxConcurrentTasksPerRegion; ++i) {
ap.incTaskCounters(Arrays.asList(hri1.getRegionName()), sn); ap.incTaskCounters(Collections.singleton(hri1.getRegionName()), sn);
} }
ap.submit(null, DUMMY_TABLE, puts, false, null, false); ap.submit(null, DUMMY_TABLE, puts, false, null, false);
Assert.assertEquals(puts.size(), 1); Assert.assertEquals(puts.size(), 1);
ap.decTaskCounters(Arrays.asList(hri1.getRegionName()), sn); ap.decTaskCounters(Collections.singleton(hri1.getRegionName()), sn);
ap.submit(null, DUMMY_TABLE, puts, false, null, false); ap.submit(null, DUMMY_TABLE, puts, false, null, false);
Assert.assertEquals(0, puts.size()); Assert.assertEquals(0, puts.size());
if (defaultClazz != null) { if (defaultClazz != null) {
@ -966,7 +967,7 @@ public class TestAsyncProcess {
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
ap.incTaskCounters(Arrays.asList("dummy".getBytes()), sn); ap.incTaskCounters(Collections.singleton("dummy".getBytes()), sn);
} }
final Thread myThread = Thread.currentThread(); final Thread myThread = Thread.currentThread();
@ -997,7 +998,7 @@ public class TestAsyncProcess {
public void run() { public void run() {
Threads.sleep(sleepTime); Threads.sleep(sleepTime);
while (controller.tasksInProgress.get() > 0) { while (controller.tasksInProgress.get() > 0) {
ap.decTaskCounters(Arrays.asList("dummy".getBytes()), sn); ap.decTaskCounters(Collections.singleton("dummy".getBytes()), sn);
} }
} }
}; };
@ -1119,6 +1120,7 @@ public class TestAsyncProcess {
Assert.assertEquals("the put should not been inserted.", 0, mutator.size()); Assert.assertEquals("the put should not been inserted.", 0, mutator.size());
} }
@SuppressWarnings("SelfComparison")
@Test @Test
public void testAction() { public void testAction() {
Action action_0 = new Action(new Put(Bytes.toBytes("abc")), 10); Action action_0 = new Action(new Put(Bytes.toBytes("abc")), 10);

View File

@ -96,6 +96,7 @@ public class TestZKUtil {
Assert.assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user6")))); Assert.assertTrue(aclList.contains(new ACL(Perms.ALL, new Id("sasl", "user6"))));
} }
@Test(expected = KeeperException.SystemErrorException.class)
public void testInterruptedDuringAction() public void testInterruptedDuringAction()
throws ZooKeeperConnectionException, IOException, KeeperException, InterruptedException { throws ZooKeeperConnectionException, IOException, KeeperException, InterruptedException {
final RecoverableZooKeeper recoverableZk = Mockito.mock(RecoverableZooKeeper.class); final RecoverableZooKeeper recoverableZk = Mockito.mock(RecoverableZooKeeper.class);
@ -107,12 +108,6 @@ public class TestZKUtil {
}; };
Mockito.doThrow(new InterruptedException()).when(recoverableZk) Mockito.doThrow(new InterruptedException()).when(recoverableZk)
.getChildren(zkw.znodePaths.baseZNode, null); .getChildren(zkw.znodePaths.baseZNode, null);
try {
ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.baseZNode); ZKUtil.listChildrenNoWatch(zkw, zkw.znodePaths.baseZNode);
} catch (KeeperException.SystemErrorException e) {
// expected
return;
}
Assert.fail("Should have thrown KeeperException but not");
} }
} }

View File

@ -174,7 +174,7 @@ public abstract class RemoteProcedureDispatcher<TEnv, TRemote extends Comparable
} }
node.add(rp); node.add(rp);
// Check our node still in the map; could have been removed by #removeNode. // Check our node still in the map; could have been removed by #removeNode.
return nodeMap.contains(node); return nodeMap.containsValue(node);
} }
/** /**

View File

@ -75,14 +75,13 @@ public class SplitLogWorker implements Runnable {
this.server = server; this.server = server;
this.conf = conf; this.conf = conf;
this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination(); this.coordination = hserver.getCoordinatedStateManager().getSplitLogWorkerCoordination();
this.server = server;
coordination.init(server, conf, splitTaskExecutor, this); coordination.init(server, conf, splitTaskExecutor, this);
} }
public SplitLogWorker(final Server hserver, final Configuration conf, public SplitLogWorker(final Server hserver, final Configuration conf,
final RegionServerServices server, final LastSequenceId sequenceIdChecker, final RegionServerServices server, final LastSequenceId sequenceIdChecker,
final WALFactory factory) { final WALFactory factory) {
this(server, conf, server, new TaskExecutor() { this(hserver, conf, server, new TaskExecutor() {
@Override @Override
public Status exec(String filename, RecoveryMode mode, CancelableProgressable p) { public Status exec(String filename, RecoveryMode mode, CancelableProgressable p) {
Path walDir; Path walDir;

View File

@ -1,61 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase;
import junit.framework.TestCase;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.experimental.categories.Category;
/**
* Test comparing HBase objects.
*/
@Category({MiscTests.class, SmallTests.class})
public class TestCompare extends TestCase {
/**
* Sort of HRegionInfo.
*/
public void testHRegionInfo() {
HRegionInfo a = new HRegionInfo(TableName.valueOf("a"), null, null);
HRegionInfo b = new HRegionInfo(TableName.valueOf("b"), null, null);
assertTrue(a.compareTo(b) != 0);
HTableDescriptor t = new HTableDescriptor(TableName.valueOf("t"));
byte [] midway = Bytes.toBytes("midway");
a = new HRegionInfo(t.getTableName(), null, midway);
b = new HRegionInfo(t.getTableName(), midway, null);
assertTrue(a.compareTo(b) < 0);
assertTrue(b.compareTo(a) > 0);
assertEquals(a, a);
assertTrue(a.compareTo(a) == 0);
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g"));
assertTrue(a.compareTo(b) < 0);
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g"));
assertTrue(a.compareTo(b) < 0);
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("eeee"));
assertTrue(a.compareTo(b) < 0);
}
}

View File

@ -63,6 +63,7 @@ public class TestHRegionLocation {
System.out.println(hrl1.toString()); System.out.println(hrl1.toString());
} }
@SuppressWarnings("SelfComparison")
@Test @Test
public void testCompareTo() { public void testCompareTo() {
ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L); ServerName hsa1 = ServerName.valueOf("localhost", 1234, -1L);
@ -71,8 +72,8 @@ public class TestHRegionLocation {
ServerName hsa2 = ServerName.valueOf("localhost", 1235, -1L); ServerName hsa2 = ServerName.valueOf("localhost", 1235, -1L);
HRegionLocation hsl2 = HRegionLocation hsl2 =
new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2); new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, hsa2);
assertTrue(hsl1.compareTo(hsl1) == 0); assertEquals(0, hsl1.compareTo(hsl1));
assertTrue(hsl2.compareTo(hsl2) == 0); assertEquals(0, hsl2.compareTo(hsl2));
int compare1 = hsl1.compareTo(hsl2); int compare1 = hsl1.compareTo(hsl2);
int compare2 = hsl2.compareTo(hsl1); int compare2 = hsl2.compareTo(hsl1);
assertTrue((compare1 > 0)? compare2 < 0: compare2 > 0); assertTrue((compare1 > 0)? compare2 < 0: compare2 > 0);

View File

@ -124,7 +124,7 @@ public class TestIPv6NIOServerSocketChannel {
//On Windows JDK6, we will get expected exception: //On Windows JDK6, we will get expected exception:
//java.net.SocketException: Address family not supported by protocol family //java.net.SocketException: Address family not supported by protocol family
//or java.net.SocketException: Protocol family not supported //or java.net.SocketException: Protocol family not supported
Assert.assertFalse(ex.getClass().isInstance(BindException.class)); Assert.assertFalse(ex instanceof BindException);
Assert.assertTrue(ex.getMessage().toLowerCase(Locale.ROOT).contains("protocol family")); Assert.assertTrue(ex.getMessage().toLowerCase(Locale.ROOT).contains("protocol family"));
LOG.info("Received expected exception:"); LOG.info("Received expected exception:");
LOG.info(ex); LOG.info(ex);

View File

@ -217,6 +217,7 @@ public class TestScannersFromClientSide2 {
testScan(456, false, 678, false, 200); testScan(456, false, 678, false, 200);
} }
@Test
public void testReversedScanWithLimit() throws Exception { public void testReversedScanWithLimit() throws Exception {
testReversedScan(998, true, 1, false, 900); // from last region to first region testReversedScan(998, true, 1, false, 900); // from last region to first region
testReversedScan(543, true, 321, true, 100); testReversedScan(543, true, 321, true, 100);

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.regionserver;
import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -169,8 +170,30 @@ public class TestHRegionInfo {
HRegionInfo newer = new HRegionInfo(tableName, empty, empty, false, 1L); HRegionInfo newer = new HRegionInfo(tableName, empty, empty, false, 1L);
assertTrue(older.compareTo(newer) < 0); assertTrue(older.compareTo(newer) < 0);
assertTrue(newer.compareTo(older) > 0); assertTrue(newer.compareTo(older) > 0);
assertTrue(older.compareTo(older) == 0); assertEquals(0, older.compareTo(older));
assertTrue(newer.compareTo(newer) == 0); assertEquals(0, newer.compareTo(newer));
HRegionInfo a = new HRegionInfo(TableName.valueOf("a"), null, null);
HRegionInfo b = new HRegionInfo(TableName.valueOf("b"), null, null);
assertNotEquals(0, a.compareTo(b));
HTableDescriptor t = new HTableDescriptor(TableName.valueOf("t"));
byte [] midway = Bytes.toBytes("midway");
a = new HRegionInfo(t.getTableName(), null, midway);
b = new HRegionInfo(t.getTableName(), midway, null);
assertTrue(a.compareTo(b) < 0);
assertTrue(b.compareTo(a) > 0);
assertEquals(a, a);
assertEquals(0, a.compareTo(a));
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("a"), Bytes.toBytes("d"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g"));
assertTrue(a.compareTo(b) < 0);
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("e"), Bytes.toBytes("g"));
assertTrue(a.compareTo(b) < 0);
a = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("dddd"));
b = new HRegionInfo(t.getTableName(), Bytes.toBytes("aaaa"), Bytes.toBytes("eeee"));
assertTrue(a.compareTo(b) < 0);
} }
@Test @Test
@ -325,7 +348,7 @@ public class TestHRegionInfo {
if (i != 1) { if (i != 1) {
Assert.assertArrayEquals(regionNameParts[i], modifiedRegionNameParts[i]); Assert.assertArrayEquals(regionNameParts[i], modifiedRegionNameParts[i]);
} else { } else {
Assert.assertNotEquals(regionNameParts[i][0], modifiedRegionNameParts[i][0]); assertNotEquals(regionNameParts[i][0], modifiedRegionNameParts[i][0]);
Assert.assertArrayEquals(modifiedRegionNameParts[1], Assert.assertArrayEquals(modifiedRegionNameParts[1],
HRegionInfo.getStartKeyForDisplay(h, conf)); HRegionInfo.getStartKeyForDisplay(h, conf));
} }

View File

@ -129,7 +129,7 @@ public class TestJoinedScanners {
puts.clear(); puts.clear();
} }
} }
if (puts.size() >= 0) { if (!puts.isEmpty()) {
ht.put(puts); ht.put(puts);
puts.clear(); puts.clear();
} }

View File

@ -58,6 +58,7 @@ import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdge; import org.apache.hadoop.hbase.util.EnvironmentEdge;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper; import org.apache.hadoop.hbase.util.EnvironmentEdgeManagerTestHelper;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
@ -599,6 +600,7 @@ public class TestStoreScanner {
} }
} }
@Test
public void testDeleteVersionMaskingMultiplePuts() throws IOException { public void testDeleteVersionMaskingMultiplePuts() throws IOException {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
KeyValue [] kvs1 = new KeyValue[] { KeyValue [] kvs1 = new KeyValue[] {
@ -623,6 +625,8 @@ public class TestStoreScanner {
assertEquals(kvs2[1], results.get(0)); assertEquals(kvs2[1], results.get(0));
} }
} }
@Test
public void testDeleteVersionsMixedAndMultipleVersionReturn() throws IOException { public void testDeleteVersionsMixedAndMultipleVersionReturn() throws IOException {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
KeyValue [] kvs1 = new KeyValue[] { KeyValue [] kvs1 = new KeyValue[] {
@ -834,10 +838,8 @@ public class TestStoreScanner {
} }
/** @Test @Ignore("this fails, since we don't handle deletions, etc, in peek")
* TODO this fails, since we don't handle deletions, etc, in peek public void testPeek() throws Exception {
*/
public void SKIP_testPeek() throws Exception {
KeyValue[] kvs = new KeyValue [] { KeyValue[] kvs = new KeyValue [] {
create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"), create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
create("R1", "cf", "a", 1, KeyValue.Type.Delete, "dont-care"), create("R1", "cf", "a", 1, KeyValue.Type.Delete, "dont-care"),

View File

@ -167,7 +167,7 @@ public class MultiThreadedUpdater extends MultiThreadedWriterBase {
get = dataGenerator.beforeGet(rowKeyBase, get); get = dataGenerator.beforeGet(rowKeyBase, get);
} catch (Exception e) { } catch (Exception e) {
// Ideally wont happen // Ideally wont happen
LOG.warn("Failed to modify the get from the load generator = [" + get.getRow() LOG.warn("Failed to modify the get from the load generator = [" + Bytes.toString(get.getRow())
+ "], column family = [" + Bytes.toString(cf) + "]", e); + "], column family = [" + Bytes.toString(cf) + "]", e);
} }
Result result = getRow(get, rowKeyBase, cf); Result result = getRow(get, rowKeyBase, cf);
@ -234,7 +234,7 @@ public class MultiThreadedUpdater extends MultiThreadedWriterBase {
if (isBatchUpdate) { if (isBatchUpdate) {
if (verbose) { if (verbose) {
LOG.debug("Preparing increment and append for key = [" LOG.debug("Preparing increment and append for key = ["
+ rowKey + "], " + columnCount + " columns"); + Bytes.toString(rowKey) + "], " + columnCount + " columns");
} }
mutate(table, inc, rowKeyBase); mutate(table, inc, rowKeyBase);
mutate(table, app, rowKeyBase); mutate(table, app, rowKeyBase);
@ -267,7 +267,7 @@ public class MultiThreadedUpdater extends MultiThreadedWriterBase {
result = table.get(get); result = table.get(get);
} catch (IOException ie) { } catch (IOException ie) {
LOG.warn( LOG.warn(
"Failed to get the row for key = [" + get.getRow() + "], column family = [" "Failed to get the row for key = [" + Bytes.toString(get.getRow()) + "], column family = ["
+ Bytes.toString(cf) + "]", ie); + Bytes.toString(cf) + "]", ie);
} }
return result; return result;

View File

@ -123,7 +123,7 @@ public class MultiThreadedWriter extends MultiThreadedWriterBase {
} }
if (isMultiPut) { if (isMultiPut) {
if (verbose) { if (verbose) {
LOG.debug("Preparing put for key = [" + rowKey + "], " + columnCount + " columns"); LOG.debug("Preparing put for key = [" + Bytes.toString(rowKey) + "], " + columnCount + " columns");
} }
insert(table, put, rowKeyBase); insert(table, put, rowKeyBase);
numCols.addAndGet(columnCount); numCols.addAndGet(columnCount);

View File

@ -1464,7 +1464,7 @@
<buildnumber.maven.version>1.4</buildnumber.maven.version> <buildnumber.maven.version>1.4</buildnumber.maven.version>
<checkstyle.version>6.18</checkstyle.version> <checkstyle.version>6.18</checkstyle.version>
<exec.maven.version>1.6.0</exec.maven.version> <exec.maven.version>1.6.0</exec.maven.version>
<error-prone.version>2.0.21</error-prone.version> <error-prone.version>2.1.1</error-prone.version>
<findbugs-annotations>1.3.9-1</findbugs-annotations> <findbugs-annotations>1.3.9-1</findbugs-annotations>
<findbugs.maven.version>3.0.4</findbugs.maven.version> <findbugs.maven.version>3.0.4</findbugs.maven.version>
<jamon.plugin.version>2.4.2</jamon.plugin.version> <jamon.plugin.version>2.4.2</jamon.plugin.version>