Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZOOKEEPER-3836: Use Commons and JDK Functions in ClientBase #1358

Closed
wants to merge 6 commits into from

Conversation

belugabehr
Copy link
Contributor

@belugabehr belugabehr commented May 19, 2020

Related to #1357

Copy link
Contributor

@nkalmar nkalmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, but please create one ticket for same refactors next time.

@@ -64,7 +66,7 @@ public void testWriteNewFile() throws IOException {
fos.close();
assertTrue(dstFile.exists());

String readBackData = ClientBase.readFile(dstFile);
String readBackData = FileUtils.readFileToString(dstFile, StandardCharsets.UTF_8);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTF_8 is one thing that can be really useful to have a static import, for readability.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there are many new ways in Java 7/8 to read from a file. I'm not sure it is necessary to rely on Commons for this. Keeping the number of uses of Commons down means that it may be easier to drop as a dependency in future, as functions are provided directly by Java itself. Fewer dependencies means greater stability in the long run, so if ZK doesn't need to use a dependency, it shouldn't.

Here are some ways to read from a File without commons, found by using Google: https://howtodoinjava.com/java/io/java-read-file-to-string-examples/

We probably want something like:

  String readBackData = new String(Files.readAllBytes(dst.toPath()), UTF_8);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on the apache commons usage. Honestly, didn't even realised it's from there, I am also used to FileUtils so much...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Made the changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@belugabehr You only changed it in one place. I only commented once, but there were many lines that were changed in the same way in the PR.

@belugabehr
Copy link
Contributor Author

Sorry for the churn. My coffee has NOT kicked in this morning obviously.

@belugabehr
Copy link
Contributor Author

@nkalmar @ctubbsii

Can you please review again? I am trying to clean out all my old PRs. :)

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looks good to me.

@asfgit asfgit closed this in 7f66c76 Nov 9, 2020
@nkalmar
Copy link
Contributor

nkalmar commented Nov 9, 2020

Merged to master, thanks @belugabehr

RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
Related to apache#1357

Author: David Mollitor <dmollitor@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes apache#1358 from belugabehr/ZOOKEEPER-3836
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
Related to apache#1357

Author: David Mollitor <dmollitor@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes apache#1358 from belugabehr/ZOOKEEPER-3836
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
Related to apache#1357

Author: David Mollitor <dmollitor@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes apache#1358 from belugabehr/ZOOKEEPER-3836
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Sep 3, 2022
Related to apache#1357

Author: David Mollitor <dmollitor@apache.org>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Norbert Kalmar <nkalmar@apache.org>

Closes apache#1358 from belugabehr/ZOOKEEPER-3836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants