Uh oh!
There was an error while loading. Please reload this page.
[SPARK-25408] Move to mode ideomatic Java8 - #22399
Conversation
AmplabJenkins
commented
Sep 11, 2018
Can one of the admins verify this patch? |
There was a problem hiding this comment.
If you are already changing this, I would also suggest to add static imports to shorten the code
There was a problem hiding this comment.
I don't think this sort of thing is worth changing. I know, IntelliJ suggests it. Unless the mutability is an issue, I'd leave it as a shorter idiom. I wouldn't use static imports here personally.
there's also a very small cost of changes in that they create potential merge conflicts for other changes later, so I tend to have a very low but finite minimum bar for value of code scrubbing like this.
There was a problem hiding this comment.
I agree, I don't really care about moving to Collections.
TomaszGaweda
commented
Sep 11, 2018
I like this idea :) +1 as it's only refactor, without logic change |
There was a problem hiding this comment.
I don't think this sort of thing is worth changing. I know, IntelliJ suggests it. Unless the mutability is an issue, I'd leave it as a shorter idiom. I wouldn't use static imports here personally.
there's also a very small cost of changes in that they create potential merge conflicts for other changes later, so I tend to have a very low but finite minimum bar for value of code scrubbing like this.
There was a problem hiding this comment.
Same comment about space above; I'd also indent the continuation 4 spaces for clarity
There was a problem hiding this comment.
Indent is now too deep here. I have the same general kind of doubt here.. it's touching a lot of lines for little actual gain. Still, I'd like to be able to improve code a bit here and there. If this is only going to master and Spark 3, the back-port issue lessens, because it's more unlikely to backport from 3.x to 2.x.
There was a problem hiding this comment.
If there are merge conflicts, it is easy to pick theirs, and wrap the try-with-resources around it.
There was a problem hiding this comment.
The scenario is something like: later, a line or two in this block is changed. That change is cherry-picked to a branch before this change here. It's a merge conflict, and choosing "theirs" overwrites your change here. It would have to be manually merged. If you know that this is all that has happened, sure, not hard. But it relies on the committer figuring that out and not missing another subtle change during the manual merge. That's definitely the most time-consuming part for me. For Spark 3.x vs 2.x I am less worried, and would like a freer hand to make small improvements. Within a major release I am reluctant.
There was a problem hiding this comment.
I wouldn't bother with this; we don't really do it consistently, it's not a JDK standard class, and it doesn't really save much, while adding to the dependency on commons/io
There was a problem hiding this comment.
This module should not have any non-JRE dependencies.
There was a problem hiding this comment.
I wan't aware of this requirement, reverted the change.
HyukjinKwon
left a comment
There was a problem hiding this comment.
was just looking through this out of curiosity. just few nits.
There was a problem hiding this comment.
Shell we stick to 2spaced indentation?
There was a problem hiding this comment.
Would it be possible to add a space after try?
1062ca6 to
a4ee101CompareFokko
commented
Sep 12, 2018
Thanks for the feedback guys, I was relying too much on Scalastyle :) |
There was a problem hiding this comment.
Good one, thanks. Missed it for some reason.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Fokko
commented
Sep 17, 2018
Addressed comments and rebased onto master, no merge conflicts. |
There was a problem hiding this comment.
nit: Can we put this line into try since this line was originally executed after clientFactory.createClient.
There was a problem hiding this comment.
No we can't, since the res is returned by the function :-)
Fokko
commented
Sep 20, 2018
@srowen Any incentive to move this forward? Or are PR's like these not appreciated? Let me know. Most of the changes are cosmetic, but having <Java8 in the codebase give a bad example to newcomers to the Spark project. Also adding the |
srowen
commented
Sep 20, 2018
I think this is fine (though see https://github.com/apache/spark/pull/22399/files#r218121426 ). As a practical matter I might wait until we're done with the 2.4 release to start a lot of changes like this. It isn't tied to Spark 2.5 or 3.0 but might just be simpler to hold this for a bit, while we might be wanting to quickly backport a few changes from master to 2.4. |
Fokko
commented
Sep 20, 2018
Cool, makes sense. Thanks for the clarification @srowen |
Use features from Java8 such as: - Try-with-resource blocks
Fokko
commented
Oct 4, 2018
Rebased onto master |
srowen
commented
Oct 5, 2018
Merged to master |
gatorsmile
commented
Oct 5, 2018
It sounds like the build is broken after merging this PR |
cloud-fan
commented
Oct 5, 2018
Jenkins was not triggered in this PR, I'm reverting it. Please re-open it and make sure jenkins pass, thanks! |
srowen
commented
Oct 5, 2018
Oh no, I got mixed up and didn't realize this one hadn't actually had a jenkins run. Sorry about this, that is my mistake. I will follow up. |
srowen
commented
Oct 5, 2018
Sorry @Fokko can you recreate this change in a new PR, after addressing... |
Fokko
commented
Oct 5, 2018
Thanks @srowen for pointing out the errors. Weird that it did not come up as a merge conflict. Let me open a new PR. |
srowen
commented
Oct 5, 2018
It wasn't a merge conflict. I failed to notice this had not actually been tested. To check locally you'd have to make sure you enable more profiles like Hive to build some of the code that changed here. |
HyukjinKwon
commented
Oct 5, 2018
@Fokko, Let's follow the PR format next time BTW, for instance, "How was this patch tested?" |
Oh I see, could we test the next PR using Jenkins? |
HyukjinKwon
commented
Oct 5, 2018
Let me trigger it in the next PR. |
Fokko
commented
Oct 5, 2018
@HyukjinKwon I've opened a new PR under #22637. Would be nice if you can trigger Travis 👍 |
While working on another PR, I noticed that there is quite some legacy Java in there that can be beautified. For example the use og features from Java8, such as: - Collection libraries - Try-with-resource blocks No code has been changed What are your thoughts on this? This makes code easier to read, and using try-with-resource makes is less likely to forget to close something. ## What changes were proposed in this pull request? (Please fill in changes proposed in this fix) ## How was this patch tested? (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests) (If this patch involves UI changes, please attach a screenshot; otherwise, remove this) Please review http://spark.apache.org/contributing.html before opening a pull request. Closesapache#22399 from Fokko/SPARK-25408. Authored-by: Fokko Driesprong <fokkodriesprong@godatadriven.com> Signed-off-by: Sean Owen <sean.owen@databricks.com>
While working on another PR, I noticed that there is quite some legacy Java in there that can be beautified. For example the use og features from Java8, such as:
No code has been changed
What are your thoughts on this?
This makes code easier to read, and using try-with-resource makes is less likely to forget to close something.
What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
Please review http://spark.apache.org/contributing.html before opening a pull request.