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

Remove calls to deprecated URL constructor #4551

Merged
merged 4 commits into from
Jan 12, 2025
Merged

Conversation

mherwege
Copy link
Contributor

@mherwege mherwege commented Jan 10, 2025

As part of #4546, it was pointed out the URL constructor has been deprecated in Java 21.

This PR removes all uses of the URL constructor in core.

It starts from #4546, which only looks at one class in HttpUtil (and also solves a different problem), so that should be reviewed first (and this one rebased afterwards).

@holgerfriedrich Let me know what you think.

@mherwege mherwege requested a review from a team as a code owner January 10, 2025 08:05
@@ -215,7 +215,7 @@ protected List<Addon> getRemoteAddons() {

// retrieve from remote
try {
URL url = new URL(String.format("%s%s", COMMUNITY_TOPIC_URL, uid.replace(ADDON_ID_PREFIX, "")));
URL url = URI.create(String.format("%s%s", COMMUNITY_TOPIC_URL, uid.replace(ADDON_ID_PREFIX, ""))).toURL();
Copy link
Contributor

Choose a reason for hiding this comment

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

While you're there, String.format("%s%s", COMMUNITY_TOPIC_URL, uid.replace(ADDON_ID_PREFIX, "")) could be replaced by "%s%s".formatted(COMMUNITY_TOPIC_URL, uid.replace(ADDON_ID_PREFIX, ""))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Or COMMUNITY_TOPIC_URL + uid.replace(ADDON_ID_PREFIX, "") 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Obviously

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Copy link
Member

@holgerfriedrich holgerfriedrich left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your work on this!

@holgerfriedrich holgerfriedrich merged commit 9ad83ba into openhab:main Jan 12, 2025
2 checks passed
@holgerfriedrich holgerfriedrich added the enhancement An enhancement or new feature of the Core label Jan 12, 2025
@holgerfriedrich holgerfriedrich added this to the 5.0 milestone Jan 12, 2025
@mherwege mherwege deleted the url branch January 12, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants