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

Java: remove URL #41

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Java: remove URL #41

merged 1 commit into from
Nov 14, 2024

Conversation

dkropachev
Copy link
Collaborator

We will need it later for #40

@dkropachev dkropachev requested review from nyh and Bouncheck November 14, 2024 16:13
Copy link

@Bouncheck Bouncheck left a comment

Choose a reason for hiding this comment

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

LGTM. I defer the approval decision to the maintainer.

return new URL(alternatorScheme, nextNode(), alternatorPort, file);
} catch (MalformedURLException e) {
return new URI(alternatorScheme, "", nextNode(), alternatorPort, file, "", "");
} catch (URISyntaxException e) {
// Can only happen if alternatorScheme is an unknown one.
logger.log(Level.WARNING, "nextAsURL", e);

Choose a reason for hiding this comment

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

This part and comment should be updated too. URI won't throw if provided with unknown to URL format scheme.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, removed the comment.

Choose a reason for hiding this comment

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

nit: nextAsURL inside logger.log( should change to nextAsURI

try {
// Note that despite this being called HttpURLConnection, it actually
// supports HTTPS as well.
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
HttpURLConnection conn = (HttpURLConnection) uri.toURL().openConnection();

Choose a reason for hiding this comment

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

note: Now if nextAsUri is provided with invalid scheme for URL we'll get MalformedURLException here instead. It's handled by catch but just wanted to make sure that's intended.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing this out, i will address it in next PRs

@nyh
Copy link
Contributor

nyh commented Nov 14, 2024

LGTM. I defer the approval decision to the maintainer.

Looks to me like you have more experience in this than I do. I don't remember what are the finer differences between URL and URI, nor did I understand what is the motivation of this change (though I can guess it has something to do with encoding the parameters, I didn't understand why URL isn't good enough for that).

@Bouncheck I see you left some review comments, please leave an approval when you are ok with the change and I can merge it.

@dkropachev
Copy link
Collaborator Author

LGTM. I defer the approval decision to the maintainer.

Looks to me like you have more experience in this than I do. I don't remember what are the finer differences between URL and URI, nor did I understand what is the motivation of this change (though I can guess it has something to do with encoding the parameters, I didn't understand why URL isn't good enough for that).

@Bouncheck I see you left some review comments, please leave an approval when you are ok with the change and I can merge it.

URL is not good enough, because we want to encode rack and datacenter parameters properly, and only URI does it.

@dkropachev dkropachev requested a review from Bouncheck November 14, 2024 18:31
@dkropachev
Copy link
Collaborator Author

@Bouncheck, could you please take a look again.

@Bouncheck
Copy link

I don't see the new changes pushed

@dkropachev dkropachev force-pushed the dk/java-switch-url-to-uri branch from f2b87eb to a3661de Compare November 14, 2024 20:20
@dkropachev
Copy link
Collaborator Author

I don't see the new changes pushed

done

@dkropachev dkropachev force-pushed the dk/java-switch-url-to-uri branch 2 times, most recently from 6f4d1a3 to 05a4676 Compare November 14, 2024 20:33
Copy link

@Bouncheck Bouncheck left a comment

Choose a reason for hiding this comment

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

LGTM, there's one typo.

return new URL(alternatorScheme, nextNode(), alternatorPort, file);
} catch (MalformedURLException e) {
return new URI(alternatorScheme, "", nextNode(), alternatorPort, file, "", "");
} catch (URISyntaxException e) {
// Can only happen if alternatorScheme is an unknown one.
logger.log(Level.WARNING, "nextAsURL", e);

Choose a reason for hiding this comment

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

nit: nextAsURL inside logger.log( should change to nextAsURI

@dkropachev dkropachev force-pushed the dk/java-switch-url-to-uri branch from 05a4676 to 6d5593d Compare November 14, 2024 21:35
@dkropachev
Copy link
Collaborator Author

LGTM, there's one typo.

thanks, fixed.

@dkropachev dkropachev merged commit 4c296a6 into master Nov 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants