Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Bartel2014-08-27 04:44:23 +0000
committerJan Bartel2014-08-27 04:46:22 +0000
commit8ce96cdd2ea5af38300b8147457e84c3eee2f48d (patch)
treecb85d5a7dbf809504fb94a9ad166e22a6d31c031 /jetty-util
parent1a0eb64a1fabccd6d4b2990e1a6864db6ac2019b (diff)
downloadorg.eclipse.jetty.project-8ce96cdd2ea5af38300b8147457e84c3eee2f48d.tar.gz
org.eclipse.jetty.project-8ce96cdd2ea5af38300b8147457e84c3eee2f48d.tar.xz
org.eclipse.jetty.project-8ce96cdd2ea5af38300b8147457e84c3eee2f48d.zip
441475 org.eclipse.jetty.server.ResourceCache exceptions under high load
Diffstat (limited to 'jetty-util')
-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.java28
2 files changed, 31 insertions, 4 deletions
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 3dbb70a9ff..2f86662af6 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
@@ -92,7 +92,7 @@ public class JarResource extends URLResource
/* ------------------------------------------------------------ */
/**
- * Returns true if the respresenetd resource exists.
+ * Returns true if the represented resource exists.
*/
@Override
public boolean exists()
@@ -118,7 +118,7 @@ public class JarResource extends URLResource
{
checkConnection();
if (!_urlString.endsWith("!/"))
- return new FilterInputStream(super.getInputStream())
+ return new FilterInputStream(getInputStream(false))
{
@Override
public void close() throws IOException {this.in=IO.getClosedStream();}
@@ -129,6 +129,9 @@ public class JarResource extends URLResource
return is;
}
+
+
+
/* ------------------------------------------------------------ */
@Override
public void copyTo(File directory)
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 b696817e50..cc302fd60b 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
@@ -197,14 +197,34 @@ public class URLResource extends Resource
return _url.toExternalForm();
}
+
/* ------------------------------------------------------------ */
/**
- * Returns an input stream to the resource
+ * Returns an input stream to the resource. The underlying
+ * url connection will be nulled out to prevent re-use.
*/
@Override
public synchronized InputStream getInputStream()
throws java.io.IOException
{
+ return getInputStream (true); //backwards compatibility
+ }
+
+
+
+ /* ------------------------------------------------------------ */
+ /**
+ * Returns an input stream to the resource, optionally nulling
+ * out the underlying url connection. If the connection is not
+ * nulled out, a subsequent call to getInputStream() may return
+ * an existing and already in-use input stream - this depends on
+ * the url protocol. Eg JarURLConnection does not reuse inputstreams.
+ *
+ * @param resetConnection if true the connection field is set to null
+ */
+ protected synchronized InputStream getInputStream(boolean resetConnection)
+ throws java.io.IOException
+ {
if (!checkConnection())
throw new IOException( "Invalid resource");
@@ -220,7 +240,11 @@ public class URLResource extends Resource
}
finally
{
- _connection=null;
+ if (resetConnection)
+ {
+ _connection=null;
+ if (LOG.isDebugEnabled()) LOG.debug("Connection nulled");
+ }
}
}

Back to the top