X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=lib%2Fjetty%2Forg%2Feclipse%2Fjetty%2Futil%2Fresource%2FURLResource.java;h=5bba2c4726570a4bfbf5ed58b6a6dd60eaa2161b;hp=b696817e50b0d6a0012eca310c7cf96c99f5cb8f;hb=ba4f228fa9f72d50991a2218cfd83987ef5d385e;hpb=875b5e9651498a0cd8e0001c0742ba843e47cad0 diff --git a/lib/jetty/org/eclipse/jetty/util/resource/URLResource.java b/lib/jetty/org/eclipse/jetty/util/resource/URLResource.java index b696817e..5bba2c47 100644 --- a/lib/jetty/org/eclipse/jetty/util/resource/URLResource.java +++ b/lib/jetty/org/eclipse/jetty/util/resource/URLResource.java @@ -1,6 +1,6 @@ // // ======================================================================== -// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. +// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. // ------------------------------------------------------------------------ // All rights reserved. This program and the accompanying materials // are made available under the terms of the Eclipse Public License v1.0 @@ -197,13 +197,33 @@ 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"); + } } } @@ -277,7 +301,7 @@ public class URLResource extends Resource path = URIUtil.canonicalPath(path); - return newResource(URIUtil.addPaths(_url.toExternalForm(),path)); + return newResource(URIUtil.addPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches); } /* ------------------------------------------------------------ */