Skip to content

Commit c4b92c2

Browse files
committed
HBASE-19761:Fix Checkstyle errors in hbase-zookeeper
1 parent adc0e85 commit c4b92c2

File tree

6 files changed

+30
-13
lines changed

6 files changed

+30
-13
lines changed

hbase-zookeeper/pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@
9191
<groupId>org.codehaus.mojo</groupId>
9292
<artifactId>findbugs-maven-plugin</artifactId>
9393
</plugin>
94+
<plugin>
95+
<groupId>org.apache.maven.plugins</groupId>
96+
<artifactId>maven-checkstyle-plugin</artifactId>
97+
<executions>
98+
<execution>
99+
<id>checkstyle</id>
100+
<phase>validate</phase>
101+
<goals>
102+
<goal>check</goal>
103+
</goals>
104+
<configuration>
105+
<failOnViolation>true</failOnViolation>
106+
</configuration>
107+
</execution>
108+
</executions>
109+
</plugin>
94110
<plugin>
95111
<groupId>net.revelc.code</groupId>
96112
<artifactId>warbucks-maven-plugin</artifactId>

hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaTableLocator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ private static AdminService.BlockingInterface getCachedConnection(ClusterConnect
388388
service = connection.getAdmin(sn);
389389
} catch (RetriesExhaustedException e) {
390390
if (e.getCause() != null && e.getCause() instanceof ConnectException) {
391-
// Catch this; presume it means the cached connection has gone bad.
391+
LOG.debug("Catch this; presume it means the cached connection has gone bad.");
392392
} else {
393393
throw e;
394394
}
@@ -407,12 +407,12 @@ private static AdminService.BlockingInterface getCachedConnection(ClusterConnect
407407
} catch (IOException ioe) {
408408
Throwable cause = ioe.getCause();
409409
if (ioe instanceof ConnectException) {
410-
// Catch. Connect refused.
410+
LOG.debug("Catch. Connect refused.");
411411
} else if (cause != null && cause instanceof EOFException) {
412-
// Catch. Other end disconnected us.
412+
LOG.debug("Catch. Other end disconnected us.");
413413
} else if (cause != null && cause.getMessage() != null &&
414414
cause.getMessage().toLowerCase(Locale.ROOT).contains("connection reset")) {
415-
// Catch. Connection reset.
415+
LOG.debug("Catch. Connection reset.");
416416
} else {
417417
throw ioe;
418418
}

hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKMainServer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public HACK_UNTIL_ZOOKEEPER_1897_ZooKeeperMain(String[] args)
5757

5858
/**
5959
* Run the command-line args passed. Calls System.exit when done.
60-
* @throws KeeperException
61-
* @throws IOException
62-
* @throws InterruptedException
60+
* @throws KeeperException zookeeper exception
61+
* @throws IOException if fail to runCmdLine
62+
* @throws InterruptedException unexpected thread exception
6363
*/
6464
void runCmdLine() throws KeeperException, IOException, InterruptedException {
6565
processCmd(this.cl);

hbase-zookeeper/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKWatcher.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
7676
// Used if abortable is null
7777
private boolean aborted = false;
7878

79-
public final ZNodePaths znodePaths;
79+
protected final ZNodePaths znodePaths;
8080

8181
// listeners to be notified
8282
private final List<ZKListener> listeners = new CopyOnWriteArrayList<>();
8383

8484
// Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL
8585
// negotiation to complete
86-
public CountDownLatch saslLatch = new CountDownLatch(1);
86+
private CountDownLatch saslLatch = new CountDownLatch(1);
8787

8888
private final Configuration conf;
8989

@@ -95,7 +95,7 @@ public class ZKWatcher implements Watcher, Abortable, Closeable {
9595
* @param identifier string that is passed to RecoverableZookeeper to be used as
9696
* identifier for this instance. Use null for default.
9797
* @throws IOException if the connection to ZooKeeper fails
98-
* @throws ZooKeeperConnectionException
98+
* @throws ZooKeeperConnectionException if the client can't connect to zookeeper
9999
*/
100100
public ZKWatcher(Configuration conf, String identifier,
101101
Abortable abortable) throws ZooKeeperConnectionException, IOException {
@@ -111,7 +111,7 @@ public ZKWatcher(Configuration conf, String identifier,
111111
* context.
112112
* @param canCreateBaseZNode true if a base ZNode can be created
113113
* @throws IOException if the connection to ZooKeeper fails
114-
* @throws ZooKeeperConnectionException
114+
* @throws ZooKeeperConnectionException if the client can't connect to zookeeper
115115
*/
116116
public ZKWatcher(Configuration conf, String identifier,
117117
Abortable abortable, boolean canCreateBaseZNode)
@@ -517,6 +517,8 @@ public void process(WatchedEvent event) {
517517
}
518518
break;
519519
}
520+
default:
521+
throw new IllegalStateException("Received event is not valid: " + event.getState());
520522
}
521523
}
522524

hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKLeaderManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hbase.zookeeper;
1919

2020
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertFalse;
2221
import static org.junit.Assert.assertNotNull;
2322
import static org.junit.Assert.assertTrue;
2423
import static org.junit.Assert.fail;

hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKMainServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class TestZKMainServer {
4343
// http://stackoverflow.com/questions/309396/java-how-to-test-methods-that-call-system-exit
4444
protected static class ExitException extends SecurityException {
4545
private static final long serialVersionUID = 1L;
46-
public final int status;
46+
private final int status;
4747
public ExitException(int status) {
4848
super("There is no escape!");
4949
this.status = status;

0 commit comments

Comments
 (0)