From 2dd667265bef3e87b65eeff8d0d4dabcf4b32a1a Mon Sep 17 00:00:00 2001 From: jglick Date: Tue, 7 Jul 2009 18:31:24 +0000 Subject: [PATCH] File.toURL() is deprecated. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19471 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/ClassicPluginStrategy.java | 12 ++++++------ .../java/hudson/lifecycle/WindowsInstallerLink.java | 2 +- core/src/main/java/hudson/model/Slave.java | 2 +- .../src/main/java/hudson/maven/agent/Main.java | 2 +- .../main/java/hudson/remoting/RemoteClassLoader.java | 6 +++--- .../test/java/hudson/remoting/DummyClassLoader.java | 2 +- .../java/org/jvnet/hudson/test/HudsonHomeLoader.java | 2 +- .../java/org/jvnet/hudson/test/HudsonTestCase.java | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 3bf57aeae1..82f9612bcc 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -123,19 +123,19 @@ public class ClassicPluginStrategy implements PluginStrategy { baseResourceURL = resolve(archive, manifest.getMainAttributes().getValue("Resource-Path")) - .toURL(); + .toURI().toURL(); } else { File classes = new File(expandDir, "WEB-INF/classes"); if (classes.exists()) - paths.add(classes.toURL()); + paths.add(classes.toURI().toURL()); File lib = new File(expandDir, "WEB-INF/lib"); File[] libs = lib.listFiles(JAR_FILTER); if (libs != null) { for (File jar : libs) - paths.add(jar.toURL()); + paths.add(jar.toURI().toURL()); } - baseResourceURL = expandDir.toURL(); + baseResourceURL = expandDir.toURI().toURL(); } File disableFile = new File(archive.getPath() + ".disabled"); if (disableFile.exists()) { @@ -259,12 +259,12 @@ public class ClassicPluginStrategy implements PluginStrategy { fs.setDir(dir); fs.setIncludes(file.getName()); for( String included : fs.getDirectoryScanner(new Project()).getIncludedFiles() ) { - paths.add(new File(dir,included).toURL()); + paths.add(new File(dir,included).toURI().toURL()); } } else { if(!file.exists()) throw new IOException("No such file: "+file); - paths.add(file.toURL()); + paths.add(file.toURI().toURL()); } } } diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index 7e303c4680..5d1365cd88 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -121,7 +121,7 @@ public class WindowsInstallerLink extends ManagementLink { copy(req, rsp, dir, getClass().getResource("/windows-service/hudson.exe"), "hudson.exe"); copy(req, rsp, dir, getClass().getResource("/windows-service/hudson.xml"), "hudson.xml"); if(!hudsonWar.getCanonicalFile().equals(new File(dir,"hudson.war").getCanonicalFile())) - copy(req, rsp, dir, hudsonWar.toURL(), "hudson.war"); + copy(req, rsp, dir, hudsonWar.toURI().toURL(), "hudson.war"); // install as a service ByteArrayOutputStream baos = new ByteArrayOutputStream(); diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index b50fa00f95..7f5b82372d 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -356,7 +356,7 @@ public abstract class Slave extends Node implements Serializable { URL res = Hudson.getInstance().servletContext.getResource("/WEB-INF/" + fileName); if(res==null) { // during the development this path doesn't have the files. - res = new URL(new File(".").getAbsoluteFile().toURL(),"target/generated-resources/WEB-INF/"+fileName); + res = new URL(new File(".").getAbsoluteFile().toURI().toURL(),"target/generated-resources/WEB-INF/"+fileName); } return res; } diff --git a/maven-agent/src/main/java/hudson/maven/agent/Main.java b/maven-agent/src/main/java/hudson/maven/agent/Main.java index c0a5fc0d77..27cd4c7c2a 100644 --- a/maven-agent/src/main/java/hudson/maven/agent/Main.java +++ b/maven-agent/src/main/java/hudson/maven/agent/Main.java @@ -114,7 +114,7 @@ public class Main { // this needs to be able to see maven. ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader()); remoting.setParent(launcher.getWorld().getRealm("plexus.core.maven")); - remoting.addConstituent(remotingJar.toURL()); + remoting.addConstituent(remotingJar.toURI().toURL()); final Socket s = new Socket((String)null,tcpPort); diff --git a/remoting/src/main/java/hudson/remoting/RemoteClassLoader.java b/remoting/src/main/java/hudson/remoting/RemoteClassLoader.java index 76a8222b66..cbd43e7187 100644 --- a/remoting/src/main/java/hudson/remoting/RemoteClassLoader.java +++ b/remoting/src/main/java/hudson/remoting/RemoteClassLoader.java @@ -137,7 +137,7 @@ final class RemoteClassLoader extends URLClassLoader { if(f.exists()) // be defensive against external factors that might have deleted this file, since we use /tmp // see http://www.nabble.com/Surefire-reports-tt17554215.html - return f.toURL(); + return f.toURI().toURL(); } long startTime = System.nanoTime(); @@ -151,7 +151,7 @@ final class RemoteClassLoader extends URLClassLoader { File res = makeResource(name, image); resourceMap.put(name,res); - return res.toURL(); + return res.toURI().toURL(); } catch (IOException e) { throw new Error("Unable to load resource "+name,e); } @@ -161,7 +161,7 @@ final class RemoteClassLoader extends URLClassLoader { Vector r = new Vector(files.size()); for (File f : files) { if(!f.exists()) return null; // abort - r.add(f.toURL()); + r.add(f.toURI().toURL()); } return r; } diff --git a/remoting/src/test/java/hudson/remoting/DummyClassLoader.java b/remoting/src/test/java/hudson/remoting/DummyClassLoader.java index d81a4eb2b2..052c42d3cc 100644 --- a/remoting/src/test/java/hudson/remoting/DummyClassLoader.java +++ b/remoting/src/test/java/hudson/remoting/DummyClassLoader.java @@ -83,7 +83,7 @@ class DummyClassLoader extends ClassLoader { os.write(loadTransformedClassImage("hudson.remoting.test.TestCallable")); os.close(); f.deleteOnExit(); - return f.toURL(); + return f.toURI().toURL(); } catch (IOException e) { return null; } diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java b/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java index dc4a25b0e2..639820a60d 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java @@ -65,7 +65,7 @@ public interface HudsonHomeLoader { * Either a zip file or a directory that contains the home image. */ public CopyExisting(File source) throws MalformedURLException { - this(source.toURL()); + this(source.toURI().toURL()); } /** diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 53dc391002..3495202e84 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -963,7 +963,7 @@ public abstract class HudsonTestCase extends TestCase { if(dir.exists() && MetaClassLoader.debugLoader==null) try { MetaClassLoader.debugLoader = new MetaClassLoader( - new URLClassLoader(new URL[]{dir.toURL()})); + new URLClassLoader(new URL[]{dir.toURI().toURL()})); } catch (MalformedURLException e) { throw new AssertionError(e); } -- GitLab