-
Notifications
You must be signed in to change notification settings - Fork 174
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
Code Improvements #331
Code Improvements #331
Conversation
76a8214
to
213d2a4
Compare
|
||
return sb.toString(); | ||
try (Stream<String> lines = Files.lines(outputFile.toPath(), Charset.forName(encoding))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use the charset StandardCharsets.UTF_8 directly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you can't because the String toString(Object o, String nullDefault)
is using the String nullDefault
... that's the reason. And furthermore it should be configurable via the outputEncoding
parameter...
String encoding = Objects.toString(outputEncoding, "UTF-8"); | ||
|
||
try (Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(out), encoding))) { | ||
String encoding = Objects.toString(outputEncoding, StandardCharsets.UTF_8.name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for this, you can use the charset object StandardCharsets.UTF_8 instead without converting to a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you can't because the String toString(Object o, String nullDefault)
is using the String nullDefault
... that's the reason.
|
||
while ((line = reader.readLine()) != null) { | ||
log.info(line); | ||
try (BufferedReader reader = new BufferedReader(new StringReader(string))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The BufferedReader probably doesn't help on a string reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately if I would use StringReader
only I don't have things like reader.lines()...
and the old code used BufferedReader
as well...
213d2a4
to
d733b36
Compare
* using Files.newBufferedWriter(), Files.lines() * using reader.lines().forEach() * Removed inverse logic. * Using StandardCharsets.UTF_8 instead of literal texts.
d733b36
to
f1b2915
Compare
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[MDEP-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
MDEP-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean verify
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean verify
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licensed under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.