mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-25 20:18:00 +01: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:
parent
8b9cd98756
commit
0ee5acc494
6 changed files with 33 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017 Grigory Fedorov, 2017-2019 Florian Schmaus
|
||||
* Copyright © 2017 Grigory Fedorov, 2017-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.
|
||||
|
@ -17,12 +17,14 @@
|
|||
package org.jivesoftware.smackx.httpfileupload.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.packet.IqData;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.parsing.SmackParsingException.SmackUriSyntaxParsingException;
|
||||
import org.jivesoftware.smack.provider.IqProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
@ -42,7 +44,7 @@ import org.jivesoftware.smackx.httpfileupload.element.Slot_V0_2;
|
|||
public class SlotProvider extends IqProvider<Slot> {
|
||||
|
||||
@Override
|
||||
public Slot parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
|
||||
public Slot parse(XmlPullParser parser, int initialDepth, IqData iqData, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException, SmackUriSyntaxParsingException {
|
||||
final String namespace = parser.getNamespace();
|
||||
|
||||
final UploadService.Version version = HttpFileUploadManager.namespaceToVersion(namespace);
|
||||
|
@ -63,7 +65,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
switch (version) {
|
||||
case v0_2:
|
||||
String putUrlString = parser.nextText();
|
||||
putUrl = new URL(putUrlString);
|
||||
putUrl = toUrl(putUrlString);
|
||||
break;
|
||||
case v0_3:
|
||||
putElementV04Content = parsePutElement_V0_4(parser);
|
||||
|
@ -85,7 +87,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
default:
|
||||
throw new AssertionError();
|
||||
}
|
||||
getUrl = new URL(getUrlString);
|
||||
getUrl = toUrl(getUrlString);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -114,7 +116,7 @@ public class SlotProvider extends IqProvider<Slot> {
|
|||
final int initialDepth = parser.getDepth();
|
||||
|
||||
String putUrlString = parser.getAttributeValue(null, "url");
|
||||
URL putUrl = new URL(putUrlString);
|
||||
URL putUrl = URI.create(putUrlString).toURL();
|
||||
|
||||
Map<String, String> headers = null;
|
||||
outerloop: while (true) {
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
|
@ -215,9 +216,9 @@ public class RoomInfo {
|
|||
if (urlField != null && !urlField.getValues().isEmpty()) {
|
||||
String urlString = urlField.getFirstValue();
|
||||
try {
|
||||
logs = new URL(urlString);
|
||||
} catch (MalformedURLException e) {
|
||||
LOGGER.log(Level.SEVERE, "Could not parse URL", e);
|
||||
logs = new URI(urlString).toURL();
|
||||
} catch (MalformedURLException | URISyntaxException e) {
|
||||
throw new IllegalArgumentException("Could not parse '" + urlString + "' to URL", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue