Skip to content

Commit 5e74895

Browse files
committed
[refactor] Use URI route to create URL
1 parent add9453 commit 5e74895

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

exist-ant/src/main/java/org/exist/ant/XMLDBXQueryTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.File;
3838
import java.io.IOException;
3939
import java.io.Writer;
40+
import java.net.URI;
4041
import java.net.URL;
4142
import java.nio.file.Files;
4243
import java.nio.file.Path;
@@ -115,7 +116,7 @@ public void execute() throws BuildException {
115116
final Resource resource = base.getResource(queryUri);
116117
source = new BinarySource((byte[]) resource.getContent(), true);
117118
} else {
118-
source = new URLSource(new URL(queryUri));
119+
source = new URLSource(URI.create(queryUri).toURL());
119120
}
120121
} else if (queryFile != null) {
121122
log("XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG);

extensions/modules/exi/src/main/java/org/exist/xquery/modules/exi/EXIUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.IOException;
2525
import java.io.InputStream;
2626
import java.net.MalformedURLException;
27+
import java.net.URI;
2728
import java.net.URL;
2829

2930
import com.evolvedbinary.j8fu.function.ConsumerE;
@@ -55,7 +56,7 @@ protected static InputStream getInputStream(Item item, XQueryContext context, fi
5556
url = "xmldb:exist://" + url;
5657
}
5758

58-
return new URL(url).openStream();
59+
return URI.create(url).toURL().openStream();
5960
case Type.ELEMENT:
6061
case Type.DOCUMENT:
6162
LOG.debug("Streaming element or document node");

extensions/modules/expathrepo/src/main/java/org/exist/xquery/modules/expathrepo/Deploy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public XarSource load(final String name, final Version version) throws IOExcepti
291291
}
292292
}
293293
LOG.info("Retrieving package from {}", pkgURL);
294-
final HttpURLConnection connection = (HttpURLConnection) new URL(pkgURL).openConnection();
294+
final HttpURLConnection connection = (HttpURLConnection) URI.create(pkgURL).toURL().openConnection();
295295
connection.setConnectTimeout(15 * 1000);
296296
connection.setReadTimeout(15 * 1000);
297297
connection.setRequestMethod("GET");

0 commit comments

Comments
 (0)