[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314570228
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
 ##
 @@ -925,15 +926,11 @@ else if (serverPath.length() > chrootPath.length())
  */
 try {
 if (packet.requestHeader.getXid() != replyHdr.getXid()) {
-packet.replyHeader.setErr(
-KeeperException.Code.CONNECTIONLOSS.intValue());
-throw new IOException("Xid out of order. Got Xid "
-+ replyHdr.getXid() + " with err " +
-+ replyHdr.getErr() +
-" expected Xid "
-+ packet.requestHeader.getXid()
-+ " for a packet with details: "
-+ packet );
+
packet.replyHeader.setErr(KeeperException.Code.CONNECTIONLOSS.intValue());
+throw new IOException("Xid out of order. Got Xid " + 
replyHdr.getXid()
+  + " with err " + +replyHdr.getErr()
 
 Review comment:
   Remove redundant `+`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314571465
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
 ##
 @@ -1268,11 +1256,7 @@ public void run() {
 } else if (e instanceof SocketException) {
 LOG.info("Socket error occurred: {}: {}", 
serverAddress, e.getMessage());
 } else {
-LOG.warn("Session 0x{} for server {}, unexpected 
error{}",
-Long.toHexString(getSessionId()),
-serverAddress,
-RETRY_CONN_MSG,
-e);
+LOG.warn("Session 0x{} for server {}, unexpected 
error{}", Long.toHexString(getSessionId()), serverAddress, RETRY_CONN_MSG, e);
 
 Review comment:
   This line after reformatting looks awfully long. Is it possible to teach 
check style so it insert line breaks when a single line exceeds certain 
preconfigured width? 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314574017
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZKUtil.java
 ##
 @@ -200,9 +195,7 @@ public static void visitSubTreeDFS(ZooKeeper zk, final 
String path, boolean watc
 }
 
 @SuppressWarnings("unchecked")
-private static void visitSubTreeDFSHelper(ZooKeeper zk, final String path,
-boolean watch, StringCallback cb)
-throws KeeperException, InterruptedException {
+private static void visitSubTreeDFSHelper(ZooKeeper zk, final String path, 
boolean watch, StringCallback cb) throws KeeperException, InterruptedException {
 
 Review comment:
   very long line again


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314574170
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ZooDefs.java
 ##
 @@ -109,45 +111,43 @@
 int ADMIN = 1 << 4;
 
 int ALL = READ | WRITE | CREATE | DELETE | ADMIN;
+
 }
 
 @InterfaceAudience.Public
 public interface Ids {
+
 /**
  * This Id represents anyone.
  */
-public final Id ANYONE_ID_UNSAFE = new Id("world", "anyone");
+Id ANYONE_ID_UNSAFE = new Id("world", "anyone");
 
 Review comment:
   this removed `final`.. intended?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314573903
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/Watcher.java
 ##
 @@ -35,34 +35,33 @@
  * This interface defines the possible states an Event may represent
  */
 @InterfaceAudience.Public
-public interface Event {
+interface Event {
+
 /**
  * Enumeration of states the ZooKeeper may be at the event
  */
 @InterfaceAudience.Public
-public enum KeeperState {
+enum KeeperState {
 /** Unused, this state is never generated by the server */
-@Deprecated
-Unknown (-1),
+@Deprecated Unknown(-1),
 
 Review comment:
   Is this intended that we want to put annotation and annotated in the same 
line?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314555258
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
 ##
 @@ -433,22 +417,22 @@ public WatcherSetEventPair(Set watchers, 
WatchedEvent event) {
  */
 private static String makeThreadName(String suffix) {
 String name = Thread.currentThread().getName().
-replaceAll("-EventThread", "");
+  
replaceAll("-EventThread", "");
 
 Review comment:
   ok. was asking just in case this was a systematic problem instead of an 
accident.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-15 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314553232
 
 

 ##
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java
 ##
 @@ -433,22 +417,22 @@ public WatcherSetEventPair(Set watchers, 
WatchedEvent event) {
  */
 private static String makeThreadName(String suffix) {
 String name = Thread.currentThread().getName().
-replaceAll("-EventThread", "");
+  
replaceAll("-EventThread", "");
 
 Review comment:
   So, check style format the line to make it look worse (comparing to old 
code)? Was it a check style bug or a by design?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313153091
 
 

 ##
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
 ##
 @@ -202,78 +201,81 @@
 }
 }
 
-static public InitialMessage parse(Long protocolVersion, 
DataInputStream din)
-throws InitialMessageException, IOException {
+public static InitialMessage parse(
+Long protocolVersion,
+DataInputStream din
+) throws InitialMessageException, IOException {
 Long sid;
 
 if (protocolVersion != PROTOCOL_VERSION) {
-throw new InitialMessageException(
-"Got unrecognized protocol version %s", 
protocolVersion);
+throw new InitialMessageException("Got unrecognized protocol 
version %s", protocolVersion);
 }
 
 sid = din.readLong();
 
 int remaining = din.readInt();
 if (remaining <= 0 || remaining > maxBuffer) {
-throw new InitialMessageException(
-"Unreasonable buffer length: %s", remaining);
+throw new InitialMessageException("Unreasonable buffer length: 
%s", remaining);
 }
 
 byte[] b = new byte[remaining];
-int num_read = din.read(b);
+int numRead = din.read(b);
 
 Review comment:
   @enixon I think my main argument on proposing of doing the naming changes as 
a future pull request instead of as part of this pull request is to ensure this 
pull request does not contain any semantic changes, make both this and the 
future pull request easier to review and evaluate. That approach has the down 
side of having to do another (or other sets of) pull requests for enabling more 
check styles rules, but I feel the benefit of staging the work out weight the 
cost of invalidate any PR or causing internal private code rebase multiple 
times, as each future pull request will be well scoped, and the amortized cost 
would likely be low for rebasing etc.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313049905
 
 

 ##
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumCnxManager.java
 ##
 @@ -202,78 +201,81 @@
 }
 }
 
-static public InitialMessage parse(Long protocolVersion, 
DataInputStream din)
-throws InitialMessageException, IOException {
+public static InitialMessage parse(
+Long protocolVersion,
+DataInputStream din
+) throws InitialMessageException, IOException {
 Long sid;
 
 if (protocolVersion != PROTOCOL_VERSION) {
-throw new InitialMessageException(
-"Got unrecognized protocol version %s", 
protocolVersion);
+throw new InitialMessageException("Got unrecognized protocol 
version %s", protocolVersion);
 }
 
 sid = din.readLong();
 
 int remaining = din.readInt();
 if (remaining <= 0 || remaining > maxBuffer) {
-throw new InitialMessageException(
-"Unreasonable buffer length: %s", remaining);
+throw new InitialMessageException("Unreasonable buffer length: 
%s", remaining);
 }
 
 byte[] b = new byte[remaining];
-int num_read = din.read(b);
+int numRead = din.read(b);
 
 Review comment:
   Can we avoid change names of variable for now? This change is not purely 
style change and might make those who maintains private patches harder. Such 
change can be done separately with a more fine grained approach.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313043052
 
 

 ##
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/test/TestHammer.java
 ##
 @@ -18,41 +18,43 @@
 
 package org.apache.zookeeper.test;
 
-
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
+import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.common.Time;
 
 public class TestHammer implements VoidCallback {
 
-static int REPS = 5;
+private static int reps = 5;
 
 Review comment:
   This is not just a style and formatting change as access level is changed. 
It seems OK, but I'd like to understand how check style works - does it do any 
reachability (possibly other types of static) analysis and make decision based 
on that?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313034715
 
 

 ##
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/util/PemReaderTest.java
 ##
 @@ -65,7 +65,7 @@ public PemReaderTest(
 }
 
 @Test
-public void testLoadPrivateKeyFromKeyStore() throws IOException, 
GeneralSecurityException {
+public void testLoadPrivateKeyFromKeyStore() throws Exception {
 
 Review comment:
   Why change the exception type here?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313037852
 
 

 ##
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/test/WatcherTest.java
 ##
 @@ -142,18 +137,16 @@ public void processResult(int rc, String path, Object 
ctx) {
 }
 }
 }
-
+
 @Test
-public void testWatcherDisconnectOnClose() 
-throws IOException, InterruptedException, KeeperException 
-{
+public void testWatcherDisconnectOnClose() throws Exception {
 
 Review comment:
   Unnecessary exception type change?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [zookeeper] hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable Checkstyle configuration on zookeeper-server

2019-08-12 Thread GitBox
hanm commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r313032932
 
 

 ##
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java
 ##
 @@ -962,14 +979,14 @@ public void dumpConnections(PrintWriter pwriter) {
 @Override
 public void resetAllConnectionStats() {
 // No need to synchronize since cnxns is backed by a ConcurrentHashMap
-for(ServerCnxn c : cnxns){
+for (ServerCnxn c : cnxns) {
 c.resetStats();
 }
 }
 
 @Override
 public Iterable> getAllConnectionInfo(boolean brief) {
-HashSet> info = new HashSet>();
+HashSet> info = new HashSet>();
 
 Review comment:
   I'd also prefer limiting the scope of this change to be mechanical changes 
that's only appertain to style and formatting.
   
   @TisonKun since you are on this, do you mind to create a couple of JIRAs to 
follow up the issues around log formatting, interface declaration and other 
nits that @enixon pointed out? 


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services