//
// ========================================================================
-// 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
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");
}
finally
{
- _connection=null;
+ if (resetConnection)
+ {
+ _connection=null;
+ if (LOG.isDebugEnabled()) LOG.debug("Connection nulled");
+ }
}
}
path = URIUtil.canonicalPath(path);
- return newResource(URIUtil.addPaths(_url.toExternalForm(),path));
+ return newResource(URIUtil.addPaths(_url.toExternalForm(),URIUtil.encodePath(path)), _useCaches);
}
/* ------------------------------------------------------------ */