[GitHub] [zookeeper] eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix SnapshotDigestTest to work with JDK12+

2019-08-29 Thread GitBox
eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix 
SnapshotDigestTest to work with JDK12+
URL: https://github.com/apache/zookeeper/pull/1056#discussion_r318972678
 
 

 ##
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/util/DigestCalculator.java
 ##
 @@ -35,18 +35,21 @@
 
 // The hardcoded digest version, should bump up this version whenever
 // we changed the digest method or fields.
-//
-// Defined it as Integer to make it able to be changed in test via 
reflection
-public static final Integer DIGEST_VERSION = 2;
+private static final int DIGEST_VERSION = 2;
 
 public static final String ZOOKEEPER_DIGEST_ENABLED = 
"zookeeper.digest.enabled";
-private static boolean digestEnabled;
 
 static {
-digestEnabled = 
Boolean.parseBoolean(System.getProperty(ZOOKEEPER_DIGEST_ENABLED, "true"));
-LOG.info("{} = {}", ZOOKEEPER_DIGEST_ENABLED, digestEnabled);
+LOG.info("{} = {}", ZOOKEEPER_DIGEST_ENABLED, 
System.getProperty(ZOOKEEPER_DIGEST_ENABLED, "true"));
 }
 
+private boolean digestEnabled;
+
+public DigestCalculator() {
 
 Review comment:
   Let's make the class 'final' it will slightly help the JVM for optimizations.
   We had 'static' methods that were not overridable.
   


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] eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix SnapshotDigestTest to work with JDK12+

2019-08-29 Thread GitBox
eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix 
SnapshotDigestTest to work with JDK12+
URL: https://github.com/apache/zookeeper/pull/1056#discussion_r318973475
 
 

 ##
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/server/DataTreeTest.java
 ##
 @@ -219,7 +219,7 @@ public void testPzxidUpdatedWhenDeletingNonExistNode() 
throws Exception {
 @Test
 public void testDigestUpdatedWhenReplayCreateTxnForExistNode() {
 try {
-DigestCalculator.setDigestEnabled(true);
+System.setProperty(DigestCalculator.ZOOKEEPER_DIGEST_ENABLED, 
"true");
 
 Review comment:
   This won't have effect of you don't instantiate a new DataTree and the 
internal DigestCalculator


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] eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix SnapshotDigestTest to work with JDK12+

2019-08-15 Thread GitBox
eolivelli commented on a change in pull request #1056: ZOOKEEPER-3495: fix 
SnapshotDigestTest to work with JDK12+
URL: https://github.com/apache/zookeeper/pull/1056#discussion_r314412180
 
 

 ##
 File path: 
zookeeper-server/src/main/java/org/apache/zookeeper/server/util/DigestCalculator.java
 ##
 @@ -37,19 +37,28 @@
 
 // The hardcoded digest version, should bump up this version whenever
 // we changed the digest method or fields.
-//
-// Defined it as Integer to make it able to be changed in test via 
reflection
-public static final Integer DIGEST_VERSION = 2;
+private static final int DIGEST_VERSION = 2;
 
+public static final DigestCalculator DIGEST_CALCULATOR;
 public static final String ZOOKEEPER_DIGEST_ENABLED = 
"zookeeper.digest.enabled";
-private static boolean digestEnabled;
 
 static {
-digestEnabled = Boolean.parseBoolean(
+boolean digestEnabled = Boolean.parseBoolean(
 System.getProperty(ZOOKEEPER_DIGEST_ENABLED, "true"));
 LOG.info("{} = {}", ZOOKEEPER_DIGEST_ENABLED, digestEnabled);
+DIGEST_CALCULATOR = new DigestCalculator(digestEnabled, 
DIGEST_VERSION);
 }
 
+
 
 Review comment:
   This is not final, why don't you add a setDigestEnabled method?
   Make it 'volatile'
   
   We won't lose much in performances


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