350634 Reverted FileResource constructor changes
This reverts commit 95ff9d73f0
.
This commit is contained in:
parent
7908c4e825
commit
2eaad85a0c
|
@ -2,6 +2,7 @@ jetty-7.4.4-SNAPSHOT
|
|||
+ 308851 Converted all jetty-client module tests to JUnit 4
|
||||
+ 345268 JDBCSessionManager does not work with maxInactiveInterval = -1
|
||||
+ 350397 SelectChannelConnector does not shutdown gracefully
|
||||
+ 350634 Reverted FileResource constructor changes
|
||||
+ 351039 Forward dispatch should retain locale
|
||||
+ 351199 HttpServletResponse.encodeURL() wrongly encodes an url without path when cookies are disabled
|
||||
+ JETTY-1153 Default charset/encoding of HTTP POST requests
|
||||
|
|
|
@ -66,16 +66,6 @@ public class FileResource extends URLResource
|
|||
{
|
||||
return __checkAliases;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
public FileResource(File file) throws MalformedURLException
|
||||
{
|
||||
super(file.toURI().toURL(),null);
|
||||
|
||||
_file=file;
|
||||
|
||||
fixUrlString();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
public FileResource(URL url)
|
||||
|
@ -83,24 +73,35 @@ public class FileResource extends URLResource
|
|||
{
|
||||
super(url,null);
|
||||
|
||||
_file =new File(url.toURI());
|
||||
try
|
||||
{
|
||||
// Try standard API to convert URL to file.
|
||||
_file =new File(new URI(url.toString()));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.ignore(e);
|
||||
try
|
||||
{
|
||||
// Assume that File.toURL produced unencoded chars. So try
|
||||
// encoding them.
|
||||
String file_url="file:"+URIUtil.encodePath(url.toString().substring(5));
|
||||
URI uri = new URI(file_url);
|
||||
if (uri.getAuthority()==null)
|
||||
_file = new File(uri);
|
||||
else
|
||||
_file = new File("//"+uri.getAuthority()+URIUtil.decodePath(url.getFile()));
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
Log.ignore(e2);
|
||||
|
||||
fixUrlString();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
FileResource(URL url, URLConnection connection, File file)
|
||||
{
|
||||
super(url,connection);
|
||||
|
||||
_file=file;
|
||||
|
||||
fixUrlString();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
private void fixUrlString()
|
||||
{
|
||||
// Still can't get the file. Doh! try good old hack!
|
||||
checkConnection();
|
||||
Permission perm = _connection.getPermission();
|
||||
_file = new File(perm==null?url.getFile():perm.getName());
|
||||
}
|
||||
}
|
||||
if (_file.isDirectory())
|
||||
{
|
||||
if (!_urlString.endsWith("/"))
|
||||
|
@ -111,6 +112,16 @@ public class FileResource extends URLResource
|
|||
if (_urlString.endsWith("/"))
|
||||
_urlString=_urlString.substring(0,_urlString.length()-1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
FileResource(URL url, URLConnection connection, File file)
|
||||
{
|
||||
super(url,connection);
|
||||
_file=file;
|
||||
if (_file.isDirectory() && !_urlString.endsWith("/"))
|
||||
_urlString=_urlString+"/";
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
|
|
@ -160,7 +160,12 @@ public abstract class Resource implements ResourceFactory
|
|||
resource=resource.substring(2);
|
||||
|
||||
File file=new File(resource).getCanonicalFile();
|
||||
return new FileResource(file);
|
||||
url=file.toURI().toURL();
|
||||
|
||||
URLConnection connection=url.openConnection();
|
||||
connection.setUseCaches(useCaches);
|
||||
FileResource fileResource= new FileResource(url,connection,file);
|
||||
return fileResource;
|
||||
}
|
||||
catch(Exception e2)
|
||||
{
|
||||
|
|
|
@ -120,11 +120,9 @@ public class ResourceTest
|
|||
__userDir = new File(perm.getName()).getCanonicalPath() + File.separatorChar;
|
||||
__relDir = "src/test/java/org/eclipse/jetty/util/resource/".replace('/', File.separatorChar);
|
||||
|
||||
/*
|
||||
System.err.println("User Dir="+__userDir);
|
||||
System.err.println("Rel Dir="+__relDir);
|
||||
System.err.println("User URL="+__userURL);
|
||||
*/
|
||||
|
||||
tmpFile=File.createTempFile("test",null).getCanonicalFile();
|
||||
tmpFile.deleteOnExit();
|
||||
|
|
Loading…
Reference in New Issue