Skip to content

Commit ddc5115

Browse files
committed
Revert "replaced 'new URL' to 'new URI' per Java 11 target codebase"
This reverts commit aeef4c1.
1 parent aeef4c1 commit ddc5115

File tree

84 files changed

+244
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+244
-244
lines changed

cli/src/main/java/hudson/cli/CLI.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public boolean verify(String s, SSLSession sslSession) {
306306
}
307307

308308
CLIConnectionFactory factory = new CLIConnectionFactory();
309-
String userInfo = new URI(url).getUserInfo();
309+
String userInfo = new URL(url).getUserInfo();
310310
if (userInfo != null) {
311311
factory = factory.basicAuth(userInfo);
312312
} else if (auth != null) {
@@ -388,7 +388,7 @@ public void close() throws IOException {
388388

389389
private static int plainHttpConnection(String url, List<String> args, CLIConnectionFactory factory) throws IOException, InterruptedException {
390390
LOGGER.log(FINE, "Trying to connect to {0} via plain protocol over HTTP", url);
391-
FullDuplexHttpStream streams = new FullDuplexHttpStream(new URI(url), "cli?remoting=false", factory.authorization);
391+
FullDuplexHttpStream streams = new FullDuplexHttpStream(new URL(url), "cli?remoting=false", factory.authorization);
392392
try (ClientSideImpl connection = new ClientSideImpl(new PlainCLIProtocol.FramedOutput(streams.getOutputStream()))) {
393393
connection.start(args);
394394
InputStream is = streams.getInputStream();

cli/src/main/java/hudson/cli/FullDuplexHttpStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public FullDuplexHttpStream(URL base, String relativeTarget, String authorizatio
5555

5656
this.base = tryToResolveRedirects(base, authorization);
5757

58-
URL target = new URI(this.base, relativeTarget);
58+
URL target = new URL(this.base, relativeTarget);
5959

6060
UUID uuid = UUID.randomUUID(); // so that the server can correlate those two connections
6161

cli/src/main/java/hudson/cli/SSHCLI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SSHCLI {
6262

6363
static int sshConnection(String jenkinsUrl, String user, List<String> args, PrivateKeyProvider provider, final boolean strictHostKey) throws IOException {
6464
Logger.getLogger(SecurityUtils.class.getName()).setLevel(Level.WARNING); // suppress: BouncyCastle not registered, using the default JCE provider
65-
URL url = new URI(jenkinsUrl + "login");
65+
URL url = new URL(jenkinsUrl + "login");
6666
URLConnection conn = openConnection(url);
6767
CLI.verifyJenkinsConnection(conn);
6868
String endpointDescription = conn.getHeaderField("X-SSH-Endpoint");

core/src/main/java/hudson/ClassicPluginStrategy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent, At
294294
}
295295
URLClassLoader2 classLoader;
296296
if (usePluginFirstClassLoader) {
297-
classLoader = new PluginFirstClassLoader2(urls.toArray(new URI[0]), parent);
297+
classLoader = new PluginFirstClassLoader2(urls.toArray(new URL[0]), parent);
298298
} else {
299-
classLoader = new URIClassLoader2(urls.toArray(new URI[0]), parent);
299+
classLoader = new URLClassLoader2(urls.toArray(new URL[0]), parent);
300300
}
301301
return classLoader;
302302
}

core/src/main/java/hudson/FilePath.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3333,12 +3333,12 @@ private int findSeparator(String pattern) {
33333333
}
33343334
}
33353335

3336-
private static final UrlFactory DEFAULT_URL_FACTORY = new URIFactory();
3336+
private static final UrlFactory DEFAULT_URL_FACTORY = new UrlFactory();
33373337

33383338
@Restricted(NoExternalUse.class)
33393339
static class UrlFactory {
33403340
public URL newURL(String location) throws MalformedURLException {
3341-
return new URI(location);
3341+
return new URL(location);
33423342
}
33433343
}
33443344

core/src/main/java/hudson/Functions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ public String getServerName() {
19391939
String url = Jenkins.get().getRootUrl();
19401940
try {
19411941
if (url != null) {
1942-
String host = new URI(url).getHost();
1942+
String host = new URL(url).getHost();
19431943
if (host != null)
19441944
return host;
19451945
}

core/src/main/java/hudson/Main.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ public static int remotePost(String[] args) throws Exception {
9999
if (!home.endsWith("/")) home = home + '/'; // make sure it ends with '/'
100100

101101
// check for authentication info
102-
String auth = new URI(home).getUserInfo();
102+
String auth = new URL(home).getUserInfo();
103103
if (auth != null) auth = "Basic " + new Base64Encoder().encode(auth.getBytes(StandardCharsets.UTF_8));
104104

105105
{ // check if the home is set correctly
106-
HttpURLConnection con = open(new URI(home));
106+
HttpURLConnection con = open(new URL(home));
107107
if (auth != null) con.setRequestProperty("Authorization", auth);
108108
con.connect();
109109
if (con.getResponseCode() != 200
@@ -113,10 +113,10 @@ public static int remotePost(String[] args) throws Exception {
113113
}
114114
}
115115

116-
URL jobURL = new URI(home + "job/" + Util.encode(projectName).replace("/", "/job/") + "/");
116+
URL jobURL = new URL(home + "job/" + Util.encode(projectName).replace("/", "/job/") + "/");
117117

118118
{ // check if the job name is correct
119-
HttpURLConnection con = open(new URI(jobURL, "acceptBuildResult"));
119+
HttpURLConnection con = open(new URL(jobURL, "acceptBuildResult"));
120120
if (auth != null) con.setRequestProperty("Authorization", auth);
121121
con.connect();
122122
if (con.getResponseCode() != 200) {
@@ -128,7 +128,7 @@ public static int remotePost(String[] args) throws Exception {
128128
// get a crumb to pass the csrf check
129129
String crumbField = null, crumbValue = null;
130130
try {
131-
HttpURLConnection con = open(new URI(home +
131+
HttpURLConnection con = open(new URL(home +
132132
"crumbIssuer/api/xml?xpath=concat(//crumbRequestField,\":\",//crumb)'"));
133133
if (auth != null) con.setRequestProperty("Authorization", auth);
134134
String line = IOUtils.readFirstLine(con.getInputStream(), "UTF-8");
@@ -165,7 +165,7 @@ public static int remotePost(String[] args) throws Exception {
165165
throw new IOException(e);
166166
}
167167

168-
URL location = new URI(jobURL, "postBuildResult");
168+
URL location = new URL(jobURL, "postBuildResult");
169169
while (true) {
170170
try {
171171
// start a remote connection
@@ -193,7 +193,7 @@ public static int remotePost(String[] args) throws Exception {
193193
} catch (HttpRetryException e) {
194194
if (e.getLocation() != null) {
195195
// retry with the new location
196-
location = new URI(e.getLocation());
196+
location = new URL(e.getLocation());
197197
continue;
198198
}
199199
// otherwise failed for reasons beyond us.

core/src/main/java/hudson/Plugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOExceptio
251251
long expires = staticLink ? TimeUnit.DAYS.toMillis(365) : -1;
252252

253253
// use serveLocalizedFile to support automatic locale selection
254-
rsp.serveLocalizedFile(req, new URI(wrapper.baseResourceURL, '.' + path), expires);
254+
rsp.serveLocalizedFile(req, new URL(wrapper.baseResourceURL, '.' + path), expires);
255255
}
256256

257257
//

core/src/main/java/hudson/PluginManager.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException {
10971097
}
10981098

10991099
/*package*/ static @CheckForNull Manifest parsePluginManifest(URL bundledJpi) {
1100-
try (URLClassLoader cl = new URIClassLoader(new URI[]{bundledJpi})) {
1100+
try (URLClassLoader cl = new URLClassLoader(new URL[]{bundledJpi})) {
11011101
InputStream in = null;
11021102
try {
11031103
URL res = cl.findResource(PluginWrapper.MANIFEST_FILENAME);
@@ -1848,7 +1848,7 @@ static class UrlPluginCopier implements PluginCopier {
18481848

18491849
@Override
18501850
public void copy(File target) throws Exception {
1851-
try (InputStream input = ProxyConfiguration.getInputStream(new URI(url))) {
1851+
try (InputStream input = ProxyConfiguration.getInputStream(new URL(url))) {
18521852
Files.copy(input, target.toPath());
18531853
}
18541854
}
@@ -1875,7 +1875,7 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
18751875
if (StringUtils.isNotBlank(items.get(1).getString())) {
18761876
// this is a URL deployment
18771877
fileName = items.get(1).getString();
1878-
copier = new URIPluginCopier(fileName);
1878+
copier = new UrlPluginCopier(fileName);
18791879
} else {
18801880
// this is a file upload
18811881
FileItem fileItem = items.get(0);
@@ -1962,7 +1962,7 @@ public HttpResponse doUploadPlugin(StaplerRequest req) throws IOException, Servl
19621962
@RequirePOST public FormValidation doCheckPluginUrl(StaplerRequest request, @QueryParameter String value) throws IOException {
19631963
if (StringUtils.isNotBlank(value)) {
19641964
try {
1965-
URL url = new URI(value);
1965+
URL url = new URL(value);
19661966
if (!url.getProtocol().startsWith("http")) {
19671967
return FormValidation.error(Messages.PluginManager_invalidUrl());
19681968
}

core/src/main/java/hudson/PluginWrapper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ public String getPluginClass() {
911911

912912
public boolean hasLicensesXml() {
913913
try {
914-
new URI(baseResourceURL, "WEB-INF/licenses.xml").openStream().close();
914+
new URL(baseResourceURL, "WEB-INF/licenses.xml").openStream().close();
915915
return true;
916916
} catch (IOException e) {
917917
return false;

core/src/main/java/hudson/ProxyConfiguration.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ private void jenkins48775workaround(Proxy proxy, URL url) {
458458
HttpURLConnection preAuth = null;
459459
try {
460460
// We do not care if there is anything at this URL, all we care is that it is using the proxy
461-
preAuth = (HttpURLConnection) new URI("http", url.getHost(), -1, "/").openConnection(proxy);
461+
preAuth = (HttpURLConnection) new URL("http", url.getHost(), -1, "/").openConnection(proxy);
462462
preAuth.setRequestMethod("HEAD");
463463
preAuth.connect();
464464
} catch (IOException e) {

core/src/main/java/hudson/TcpSlaveAgentListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public String getAdvertisedHost() {
135135
return CLI_HOST_NAME;
136136
}
137137
try {
138-
return new URI(Jenkins.get().getRootUrl()).getHost();
138+
return new URL(Jenkins.get().getRootUrl()).getHost();
139139
} catch (MalformedURLException e) {
140140
throw new IllegalStateException("Could not get TcpSlaveAgentListener host name", e);
141141
}

core/src/main/java/hudson/WebAppMain.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public Locale get() {
170170
JVM jvm;
171171
try {
172172
jvm = new JVM();
173-
new URIClassLoader(new URI[0], getClass().getClassLoader());
173+
new URLClassLoader(new URL[0], getClass().getClassLoader());
174174
} catch (SecurityException e) {
175175
throw new InsufficientPermissionDetected(e);
176176
}

core/src/main/java/hudson/cli/InstallPluginCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ protected int run() throws Exception {
104104

105105
// is this an URL?
106106
try {
107-
URL u = new URI(source);
107+
URL u = new URL(source);
108108
stdout.println(Messages.InstallPluginCommand_InstallingPluginFromUrl(u));
109109
File f = getTmpFile();
110110
FileUtils.copyURLToFile(u, f); // TODO JENKINS-58248 proxy

core/src/main/java/hudson/console/UrlAnnotator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
public class UrlAnnotator extends ConsoleAnnotatorFactory<Object> {
1717
@Override
1818
public ConsoleAnnotator newInstance(Object context) {
19-
return new URIConsoleAnnotator();
19+
return new UrlConsoleAnnotator();
2020
}
2121

2222
private static class UrlConsoleAnnotator extends ConsoleAnnotator {

core/src/main/java/hudson/model/DownloadService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public FormValidation updateNow() throws IOException {
388388
}
389389
String jsonString;
390390
try {
391-
jsonString = loadJSONHTML(new URI(site + ".html?id=" + URLEncoder.encode(getId(), StandardCharsets.UTF_8) + "&version=" + URLEncoder.encode(Jenkins.VERSION, StandardCharsets.UTF_8)));
391+
jsonString = loadJSONHTML(new URL(site + ".html?id=" + URLEncoder.encode(getId(), StandardCharsets.UTF_8) + "&version=" + URLEncoder.encode(Jenkins.VERSION, StandardCharsets.UTF_8)));
392392
toolInstallerMetadataExists = true;
393393
} catch (Exception e) {
394394
LOGGER.log(Level.FINE, "Could not load json from " + site, e);

core/src/main/java/hudson/model/UpdateCenter.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ public UpdateCenterConfiguration() {
12071207
* @throws IOException if a connection can't be established
12081208
*/
12091209
public void checkConnection(ConnectionCheckJob job, String connectionCheckUrl) throws IOException {
1210-
testConnection(new URI(connectionCheckUrl));
1210+
testConnection(new URL(connectionCheckUrl));
12111211
}
12121212

12131213
/**
@@ -1230,9 +1230,9 @@ public void checkUpdateCenter(ConnectionCheckJob job, String updateCenterUrl) th
12301230
static URL toUpdateCenterCheckUrl(String updateCenterUrl) throws MalformedURLException {
12311231
URL url;
12321232
if (updateCenterUrl.startsWith("http://") || updateCenterUrl.startsWith("https://")) {
1233-
url = new URI(updateCenterUrl + (updateCenterUrl.indexOf('?') == -1 ? "?uctest" : "&uctest"));
1233+
url = new URL(updateCenterUrl + (updateCenterUrl.indexOf('?') == -1 ? "?uctest" : "&uctest"));
12341234
} else {
1235-
url = new URI(updateCenterUrl);
1235+
url = new URL(updateCenterUrl);
12361236
}
12371237
return url;
12381238
}
@@ -2193,7 +2193,7 @@ public InstallationJob(Plugin plugin, UpdateSite site, Authentication auth, bool
21932193

21942194
@Override
21952195
protected URL getURL() throws MalformedURLException {
2196-
return new URI(plugin.url);
2196+
return new URL(plugin.url);
21972197
}
21982198

21992199
@Override
@@ -2422,7 +2422,7 @@ public PluginDowngradeJob(Plugin plugin, UpdateSite site, Authentication auth) {
24222422

24232423
@Override
24242424
protected URL getURL() throws MalformedURLException {
2425-
return new URI(plugin.url);
2425+
return new URL(plugin.url);
24262426
}
24272427

24282428
@Override
@@ -2517,7 +2517,7 @@ protected URL getURL() throws MalformedURLException {
25172517
if (site == null) {
25182518
throw new MalformedURLException("no update site defined");
25192519
}
2520-
return new URI(site.getData().core.url);
2520+
return new URL(site.getData().core.url);
25212521
}
25222522

25232523
@Override
@@ -2564,7 +2564,7 @@ protected URL getURL() throws MalformedURLException {
25642564
if (site == null) {
25652565
throw new MalformedURLException("no update site defined");
25662566
}
2567-
return new URI(site.getData().core.url);
2567+
return new URL(site.getData().core.url);
25682568
}
25692569

25702570
@Override

core/src/main/java/hudson/model/UpdateSite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public long getDataTimestamp() {
215215

216216
@Restricted(NoExternalUse.class)
217217
public @NonNull FormValidation updateDirectlyNow(boolean signatureCheck) throws IOException {
218-
return updateData(DownloadService.loadJSON(new URI(getUrl() + "?id=" + URLEncoder.encode(getId(), StandardCharsets.UTF_8) + "&version=" + URLEncoder.encode(Jenkins.VERSION, StandardCharsets.UTF_8))), signatureCheck);
218+
return updateData(DownloadService.loadJSON(new URL(getUrl() + "?id=" + URLEncoder.encode(getId(), StandardCharsets.UTF_8) + "&version=" + URLEncoder.encode(Jenkins.VERSION, StandardCharsets.UTF_8))), signatureCheck);
219219
}
220220

221221
private FormValidation updateData(String json, boolean signatureCheck)

core/src/main/java/hudson/scm/RepositoryBrowser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected static URL normalizeToEndWithSlash(URL url) {
8888
String q = url.getQuery();
8989
q = q != null ? '?' + q : "";
9090
try {
91-
return new URI(url, url.getPath() + '/' + q);
91+
return new URL(url, url.getPath() + '/' + q);
9292
} catch (MalformedURLException e) {
9393
// impossible
9494
throw new Error(e);

core/src/main/java/hudson/tools/DownloadFromUrlInstaller.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public FilePath performInstallation(ToolInstallation tool, Node node, TaskListen
7474
if (isUpToDate(expected, inst))
7575
return expected;
7676

77-
if (expected.installIfNecessaryFrom(new URI(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) {
77+
if (expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) {
7878
expected.child(".timestamp").delete(); // we don't use the timestamp
7979
FilePath base = findPullUpDirectory(expected);
8080
if (base != null && base != expected)

core/src/main/java/hudson/tools/ZipExtractionInstaller.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public String getSubdir() {
8383
@Override
8484
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException {
8585
FilePath dir = preferredLocation(tool, node);
86-
if (dir.installIfNecessaryFrom(new URI(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) {
86+
if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) {
8787
dir.act(new ChmodRecAPlusX());
8888
}
8989
if (subdir == null) {

core/src/main/java/hudson/util/FormFieldValidator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ protected void check() throws IOException, ServletException {
335335
if (!value.endsWith("/")) value += '/';
336336

337337
try {
338-
URL url = new URI(value);
338+
URL url = new URL(value);
339339
HttpURLConnection con = openConnection(url);
340340
con.connect();
341341
if (con.getResponseCode() != 200

core/src/main/java/jenkins/install/SetupWizard.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public JSONArray getPlatformPluginUpdates() {
561561
suggestedPluginUrl = suggestedPluginUrl + (suggestedPluginUrl.contains("?") ? "&" : "?") + "version=" + version;
562562
}
563563
try {
564-
URLConnection connection = ProxyConfiguration.open(new URI(suggestedPluginUrl));
564+
URLConnection connection = ProxyConfiguration.open(new URL(suggestedPluginUrl));
565565

566566
try {
567567
String initialPluginJson = IOUtils.toString(connection.getInputStream(), StandardCharsets.UTF_8);

core/src/main/java/jenkins/org/apache/commons/validator/routines/UrlValidator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* Construct a UrlValidator with valid schemes of "http", and "https".
5151
*
5252
* String[] schemes = {"http","https"}.
53-
* UrlValidator urlValidator = new URIValidator(schemes);
53+
* UrlValidator urlValidator = new UrlValidator(schemes);
5454
* if (urlValidator.isValid("ftp://foo.bar.com/")) {
5555
* System.out.println("url is valid");
5656
* } else {
@@ -60,7 +60,7 @@
6060
* prints "url is invalid"
6161
* If instead the default constructor is used.
6262
*
63-
* UrlValidator urlValidator = new URIValidator();
63+
* UrlValidator urlValidator = new UrlValidator();
6464
* if (urlValidator.isValid("ftp://foo.bar.com/")) {
6565
* System.out.println("url is valid");
6666
* } else {
@@ -179,7 +179,7 @@ public class UrlValidator implements Serializable {
179179
/**
180180
* Singleton instance of this class with default schemes and options.
181181
*/
182-
private static final UrlValidator DEFAULT_URL_VALIDATOR = new URIValidator();
182+
private static final UrlValidator DEFAULT_URL_VALIDATOR = new UrlValidator();
183183

184184
/**
185185
* Returns the singleton instance of this class with default schemes and options.

0 commit comments

Comments
 (0)