-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8345249: Apply some conservative cleanups in FileURLConnection #22459
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back eirbjo! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
This PR consists of the following commits:
|
4df4e86
to
d990e83
Compare
String[] fileList = file.list(); | ||
if (fileList == null) | ||
throw new FileNotFoundException(file.getPath() + " exists, but is not accessible"); | ||
directoryListing = Arrays.<String>asList(fileList); |
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.
Is the <String>
parameterization necessary? I tested on jshell, and it seems since the destination variable's type is List<String>
we don't need this explicit parameterization to distinguish varargs.
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.
Yes, indeed this can be dropped. See 06b2a23.
for (int i = 0 ; i < files.size() ; i++) { | ||
String fileName = files.get(i); | ||
for (int i = 0; i < directoryListing.size() ; i++) { | ||
String fileName = directoryListing.get(i); | ||
sb.append(fileName); | ||
sb.append("\n"); |
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.
We can use a StringJoiner
or stream to join the strings instead. (Note there is a suffix \n
in the strings)
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.
StringJoiner
will not include the trailing line break. I want to be conservative in this PR so reluctant to introduce streams for this.
Opted to use an enhanced for-loop. See f9efa3b.
EDIT: Aha, StringJoiner
, not String.join
:-) Still, I think I prefer keeping the explicit iteration for this PR.
Webrevs
|
Please review this PR which applies various cleanups to
sun.net.www.protocol.file.FileURLConnection
.This class is known to be an old, intricate, and hard to maintain piece of code. However, there are some relatively straightforward refactorings / cleanups possible which improve readability and makes it easier to reason about what's going on in this class.
In this PR, I have chosen to make each individual small change a separate commit. This to assist review of each individual change, which can otherwise disappear a bit when reviewing the PR as a whole.
A detailed listing of each commit follows in a separate comment.
This is a pure cleanup PR, no tests are added or updated in this PR.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22459/head:pull/22459
$ git checkout pull/22459
Update a local copy of the PR:
$ git checkout pull/22459
$ git pull https://git.openjdk.org/jdk.git pull/22459/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22459
View PR using the GUI difftool:
$ git pr show -t 22459
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22459.diff
Using Webrev
Link to Webrev Comment