1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Remove usage of deprecated URL constructor

Although those URL constructors are only deprecated with Java 20, this
already removes their usage.
This commit is contained in:
Florian Schmaus 2024-10-15 15:45:47 +02:00
parent 8b9cd98756
commit 0ee5acc494
6 changed files with 33 additions and 13 deletions

View file

@ -18,6 +18,7 @@ package org.jivesoftware.smack;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.logging.Logger;
@ -35,7 +36,7 @@ public class Smack {
static {
try {
BUG_REPORT_URL = new URL("https://discourse.igniterealtime.org/c/smack/smack-support/9");
BUG_REPORT_URL = URI.create("https://discourse.igniterealtime.org/c/smack/smack-support/9").toURL();
} catch (MalformedURLException e) {
throw new ExceptionInInitializerError(e);
}

View file

@ -18,6 +18,7 @@
package org.jivesoftware.smack;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@ -60,7 +61,7 @@ public final class SmackConfiguration {
static {
try {
SMACK_URL = new URL(SMACK_URL_STRING);
SMACK_URL = URI.create(SMACK_URL_STRING).toURL();
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}

View file

@ -117,7 +117,7 @@ public final class HttpLookupMethod {
*/
public static InputStream getXrdStream(DomainBareJid xmppServiceAddress) throws IOException {
final String metadataUrl = "https://" + xmppServiceAddress + "/.well-known/host-meta";
final URL putUrl = new URL(metadataUrl);
final URL putUrl = URI.create(metadataUrl).toURL();
final URLConnection urlConnection = putUrl.openConnection();
return urlConnection.getInputStream();
}

View file

@ -1,6 +1,6 @@
/**
*
* Copyright 2019-2021 Florian Schmaus
* Copyright 2019-2024 Florian Schmaus
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,10 +20,15 @@ import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import org.jivesoftware.smack.packet.Element;
import org.jivesoftware.smack.parsing.SmackParsingException;
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
import org.jivesoftware.smack.xml.XmlPullParserException;
public class AbstractProvider<E extends Element> {
@ -106,4 +111,14 @@ public class AbstractProvider<E extends Element> {
return e;
}
public static URL toUrl(String string) throws SmackUriSyntaxParsingException, MalformedURLException {
URI uri;
try {
uri = new URI(string);
} catch (URISyntaxException e) {
throw new SmackUriSyntaxParsingException(e);
}
return uri.toURL();
}
}