merge from jetty-8

This commit is contained in:
Jesse McConnell 2013-02-15 12:47:04 -06:00
parent 94a344289b
commit 39c5d6c141
7 changed files with 41 additions and 14 deletions

View File

@ -65,6 +65,19 @@ class JarFileResource extends JarResource
_list=null; _list=null;
_entry=null; _entry=null;
_file=null; _file=null;
if ( _jarFile != null )
{
try
{
_jarFile.close();
}
catch ( IOException ioe )
{
LOG.ignore(ioe);
}
}
_jarFile=null; _jarFile=null;
super.release(); super.release();
} }
@ -303,12 +316,11 @@ class JarFileResource extends JarResource
throw new IllegalStateException(); throw new IllegalStateException();
} }
Enumeration e=jarFile.entries(); Enumeration<JarEntry> e=jarFile.entries();
String dir=_urlString.substring(_urlString.indexOf("!/")+2); String dir=_urlString.substring(_urlString.indexOf("!/")+2);
while(e.hasMoreElements()) while(e.hasMoreElements())
{ {
JarEntry entry = e.nextElement();
JarEntry entry = (JarEntry) e.nextElement();
String name=entry.getName().replace('\\','/'); String name=entry.getName().replace('\\','/');
if(!name.startsWith(dir) || name.length()==dir.length()) if(!name.startsWith(dir) || name.length()==dir.length())
{ {

View File

@ -32,8 +32,13 @@ import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.TimeZone;
import java.util.jar.JarFile;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import junit.framework.Assert;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.toolchain.test.OS; import org.eclipse.jetty.toolchain.test.OS;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
@ -122,10 +127,14 @@ public class ResourceTest
URI uri = file.toURI(); URI uri = file.toURI();
__userURL=uri.toURL(); __userURL=uri.toURL();
__userURL = new URL(__userURL.toString() + "src/test/resources/org/eclipse/jetty/util/resource/"); __userURL = MavenTestingUtils.getTestResourcesDir().toURI().toURL();
FilePermission perm = (FilePermission) __userURL.openConnection().getPermission(); FilePermission perm = (FilePermission) __userURL.openConnection().getPermission();
__userDir = new File(perm.getName()).getCanonicalPath() + File.separatorChar; __userDir = new File(perm.getName()).getCanonicalPath() + File.separatorChar;
__relDir = "src/test/resources/org/eclipse/jetty/util/resource/".replace('/', File.separatorChar); __relDir = "src/test/resources/".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=File.createTempFile("test",null).getCanonicalFile();
tmpFile.deleteOnExit(); tmpFile.deleteOnExit();
@ -319,7 +328,9 @@ public class ResourceTest
throws Exception throws Exception
{ {
String s = "jar:"+__userURL+"TestData/test.zip!/subdir/numbers"; String s = "jar:"+__userURL+"TestData/test.zip!/subdir/numbers";
ZipFile zf = new ZipFile(MavenTestingUtils.getProjectFile("src/test/resources/org/eclipse/jetty/util/resource/TestData/test.zip"));
ZipFile zf = new ZipFile(MavenTestingUtils.getTestResourceFile("TestData/test.zip"));
long last = zf.getEntry("subdir/numbers").getTime(); long last = zf.getEntry("subdir/numbers").getTime();

View File

@ -60,10 +60,14 @@ public abstract class Descriptor
if (_root == null) if (_root == null)
{ {
//boolean oldValidating = _processor.getParser().getValidating(); try
//_processor.getParser().setValidating(_validating); {
_root = _parser.parse(_xml.getURL().toString()); _root = _parser.parse(_xml.getInputStream());
//_processor.getParser().setValidating(oldValidating); }
finally
{
_xml.release();
}
} }
} }