Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--VERSION.txt1
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java13
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java7
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java5
-rw-r--r--jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java59
5 files changed, 75 insertions, 10 deletions
diff --git a/VERSION.txt b/VERSION.txt
index cc1d36a346..5b79ebcc05 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -3,6 +3,7 @@
+ 328789 Clean up tmp files from test harnesses
+ 331230 Fixed low thread warnings when acceptors>threadpool
+ 331461 Fixed idle timeout for unflushed HTTP/1.0
+ + JETTY-1307 Check that JarFileResource directories end with /
jetty-7.2.2.v20101201 1 December 2010
+ 330210 Improve performance of writing large bytes arrays
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java
index a7fdc9f7ee..a7ba967139 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarFileResource.java
@@ -185,6 +185,19 @@ class JarFileResource extends JarResource
break;
}
}
+
+ if (_directory && !_urlString.endsWith("/"))
+ {
+ _urlString+="/";
+ try
+ {
+ _url=new URL(_urlString);
+ }
+ catch(MalformedURLException ex)
+ {
+ Log.warn(ex);
+ }
+ }
}
}
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java
index c79b1a6ed4..3362725133 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/JarResource.java
@@ -125,6 +125,9 @@ public class JarResource extends URLResource
public void copyTo(File directory)
throws IOException
{
+ if (!exists())
+ return;
+
if(Log.isDebugEnabled())Log.debug("Extract "+this+" to "+directory);
String urlString = this.getURL().toExternalForm().trim();
@@ -150,6 +153,10 @@ public class JarResource extends URLResource
String entryName = entry.getName();
if ((subEntryName != null) && (entryName.startsWith(subEntryName)))
{
+ // is the subentry really a dir?
+ if (!subEntryIsDir && subEntryName.length()+1==entryName.length() && entryName.endsWith("/"))
+ subEntryIsDir=true;
+
//if there is a particular subEntry that we are looking for, only
//extract it.
if (subEntryIsDir)
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java
index f7629c9c2b..c6b5c14d48 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/URLResource.java
@@ -26,13 +26,10 @@ import org.eclipse.jetty.util.log.Log;
/* ------------------------------------------------------------ */
/** Abstract resource class.
- *
- *
- *
*/
public class URLResource extends Resource
{
- protected final URL _url;
+ protected URL _url;
protected String _urlString;
protected URLConnection _connection;
diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
index dbb9f87637..59aba3715d 100644
--- a/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
+++ b/jetty-util/src/test/java/org/eclipse/jetty/util/resource/ResourceTest.java
@@ -24,6 +24,9 @@ import java.io.FilenameFilter;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
import java.util.jar.JarInputStream;
import org.eclipse.jetty.util.IO;
@@ -33,7 +36,6 @@ import org.junit.Test;
public class ResourceTest
{
-
public static String __userDir = System.getProperty("basedir", ".");
public static URL __userURL=null;
private static String __relDir="";
@@ -237,13 +239,58 @@ public class ResourceTest
public void testJarFile()
throws Exception
{
-
String s = "jar:"+__userURL+"TestData/test.zip!/subdir/";
Resource r = Resource.newResource(s);
- InputStream is = r.getInputStream();
- JarInputStream jin = new JarInputStream(is);
- assertNotNull(is);
- assertNotNull(jin);
+
+ Set entries = new HashSet(Arrays.asList(r.list()));
+ assertEquals(3,entries.size());
+ assertTrue(entries.contains("alphabet"));
+ assertTrue(entries.contains("numbers"));
+ assertTrue(entries.contains("subsubdir/"));
+
+ File extract = File.createTempFile("extract", null);
+ if (extract.exists())
+ extract.delete();
+ extract.mkdir();
+ extract.deleteOnExit();
+
+ r.copyTo(extract);
+
+ Resource e = Resource.newResource(extract.getAbsolutePath());
+
+ entries = new HashSet(Arrays.asList(e.list()));
+ assertEquals(3,entries.size());
+ assertTrue(entries.contains("alphabet"));
+ assertTrue(entries.contains("numbers"));
+ assertTrue(entries.contains("subsubdir/"));
+ IO.delete(extract);
+
+ s = "jar:"+__userURL+"TestData/test.zip!/subdir/subsubdir/";
+ r = Resource.newResource(s);
+
+ entries = new HashSet(Arrays.asList(r.list()));
+ assertEquals(2,entries.size());
+ assertTrue(entries.contains("alphabet"));
+ assertTrue(entries.contains("numbers"));
+
+ extract = File.createTempFile("extract", null);
+ if (extract.exists())
+ extract.delete();
+ extract.mkdir();
+ extract.deleteOnExit();
+
+ r.copyTo(extract);
+
+ e = Resource.newResource(extract.getAbsolutePath());
+
+ entries = new HashSet(Arrays.asList(e.list()));
+ assertEquals(2,entries.size());
+ assertTrue(entries.contains("alphabet"));
+ assertTrue(entries.contains("numbers"));
+ IO.delete(extract);
+
+
+
}
@Test

Back to the top