351576 Do not use deprecated method File.toURL()
This commit is contained in:
parent
4e8598eb00
commit
8babf3ae17
|
@ -1,5 +1,6 @@
|
|||
jetty-7.5.0-SNAPSHOT
|
||||
+ 351516 Refactored sessions to better support nosql session managers
|
||||
+ 351576 Do not use deprecated method File.toURL()
|
||||
|
||||
jetty-7.4.4.v20110707 July 7th 2011
|
||||
+ 308851 Converted all jetty-client module tests to JUnit 4
|
||||
|
|
|
@ -219,7 +219,7 @@ public class ContextDeployer extends AbstractLifeCycle
|
|||
@Deprecated
|
||||
public void setConfigurationDir(File file) throws Exception
|
||||
{
|
||||
setConfigurationDir(Resource.newResource(file.toURL()));
|
||||
setConfigurationDir(Resource.newResource(Resource.toURL(file)));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MockAppProvider extends AbstractLifeCycle implements AppProvider
|
|||
WebAppContext context = new WebAppContext();
|
||||
|
||||
File war = new File(webappsDir,app.getOriginId().substring(5));
|
||||
context.setWar(Resource.newResource(war.toURI().toURL()).toString());
|
||||
context.setWar(Resource.newResource(Resource.toURL(war)).toString());
|
||||
|
||||
String path = war.getName();
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|||
import org.eclipse.jetty.toolchain.test.PathAssert;
|
||||
import org.eclipse.jetty.toolchain.test.TestingDir;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.eclipse.jetty.xml.XmlConfiguration;
|
||||
import org.junit.Assert;
|
||||
|
@ -132,7 +133,7 @@ public class XmlConfiguredJetty
|
|||
|
||||
public void addConfiguration(File xmlConfigFile) throws MalformedURLException
|
||||
{
|
||||
_xmlConfigurations.add(xmlConfigFile.toURI().toURL());
|
||||
_xmlConfigurations.add(Resource.toURL(xmlConfigFile));
|
||||
}
|
||||
|
||||
public void addConfiguration(String testConfigName) throws MalformedURLException
|
||||
|
|
|
@ -271,7 +271,7 @@ public class ContextHandlerTest
|
|||
ContextHandler handler = new ContextHandler();
|
||||
|
||||
assertTrue("Not a directory " + testDirectory,testDirectory.isDirectory());
|
||||
handler.setBaseResource(Resource.newResource(testDirectory.toURI().toURL()));
|
||||
handler.setBaseResource(Resource.newResource(Resource.toURL(testDirectory)));
|
||||
|
||||
List<String> paths = new ArrayList<String>(handler.getResourcePaths(root));
|
||||
assertEquals(2,paths.size());
|
||||
|
|
|
@ -127,7 +127,7 @@ public class Classpath {
|
|||
URL[] urls = new URL[cnt];
|
||||
for (int i=0; i < cnt; i++) {
|
||||
try {
|
||||
String u=((_elements.elementAt(i))).toURL().toString();
|
||||
String u=_elements.elementAt(i).toURI().toURL().toString();
|
||||
urls[i] = new URL(encodeFileURL(u));
|
||||
} catch (MalformedURLException e) {}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class FileResource extends URLResource
|
|||
String can=_file.getCanonicalPath();
|
||||
|
||||
if (abs.length()!=can.length() || !abs.equals(can))
|
||||
_alias=new File(can).toURI().toURL();
|
||||
_alias=Resource.toURL(new File(can));
|
||||
|
||||
_aliasChecked=true;
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ public abstract class Resource implements ResourceFactory
|
|||
resource=resource.substring(2);
|
||||
|
||||
File file=new File(resource).getCanonicalFile();
|
||||
url=file.toURI().toURL();
|
||||
url=Resource.toURL(file);
|
||||
|
||||
URLConnection connection=url.openConnection();
|
||||
connection.setUseCaches(useCaches);
|
||||
|
@ -642,5 +642,15 @@ public abstract class Resource implements ResourceFactory
|
|||
throw new IllegalArgumentException(destination+" exists");
|
||||
writeTo(new FileOutputStream(destination),0,-1);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Generate a properly encoded URL from a {@link File} instance.
|
||||
* @param file Target file.
|
||||
* @return URL of the target file.
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
public static URL toURL(File file) throws MalformedURLException
|
||||
{
|
||||
return Resource.toURL(file);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.xml.parsers.SAXParserFactory;
|
|||
|
||||
import org.eclipse.jetty.util.LazyList;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
|
@ -212,7 +213,7 @@ public class XmlParser
|
|||
{
|
||||
if (Log.isDebugEnabled())
|
||||
Log.debug("parse: " + file);
|
||||
return parse(new InputSource(file.toURL().toString()));
|
||||
return parse(new InputSource(Resource.toURL(file).toString()));
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue