[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user asfgit closed the pull request at: https://github.com/apache/zookeeper/pull/140 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user hanm commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94512540 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); --- End diff -- Re null equality - code updated to make the semantic more explicit - basically I think we don't need to deal with null in this context, so forbid them in first place. The previous null check code was just muscle memory when writing code : ) --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user hanm commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94511184 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); --- End diff -- @eribeiro code updated to use File.equals, which is less verbose. Thanks for pointing this out. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user eribeiro commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94510206 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); --- End diff -- Also, ``checkEquality(null, null)`` here will be false. We want this? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user eribeiro commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94510094 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); +} catch (IOException e) { --- End diff -- Oh, I see. It is because the method overloading. But could we add a comment like ``//DO NOTHING`` or maybe log the error in the ``catch`` body? Empty catch blocks make me uncomfortable. :) But I am fine as is, nevertheless. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user eribeiro commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94507574 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); --- End diff -- I am almost sure you could use ``new File(a).equals(b)`` here. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[GitHub] zookeeper pull request #140: ZOOKEEPER-2656: Fix ServerConfigTest#testValidA...
Github user eribeiro commented on a diff in the pull request: https://github.com/apache/zookeeper/pull/140#discussion_r94507355 --- Diff: src/java/test/org/apache/zookeeper/ServerConfigTest.java --- @@ -57,4 +59,16 @@ public void testTooManyArguments() { String[] args = {"2181", "/data/dir", "6", "1", ""}; serverConfig.parse(args); } -} + +boolean checkEquality(String a, String b) { +return a != null && a.equals(b); +} + +boolean checkEquality(String a, File b) { +try { +return a != null && b != null && new File(a).getCanonicalPath().equals(b.getCanonicalPath()); +} catch (IOException e) { --- End diff -- Why not let this method throw ``IOException`` and change the caller accordingly? --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---