//
// ========================================================================
-// 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
{
try
{
- LOG.debug("Closing JarFile "+_jarFile.getName());
+ if (LOG.isDebugEnabled())
+ LOG.debug("Closing JarFile "+_jarFile.getName());
_jarFile.close();
}
catch ( IOException ioe )
* Returns true if the represented resource exists.
*/
@Override
+
public boolean exists()
{
if (_exists)
else
{
// Can we find a file for it?
- JarFile jarFile=null;
+ boolean close_jar_file= false;
+ JarFile jar_file=null;
if (check)
// Yes
- jarFile=_jarFile;
+ jar_file=_jarFile;
else
{
// No - so lets look if the root entry exists.
{
JarURLConnection c=(JarURLConnection)((new URL(_jarUrl)).openConnection());
c.setUseCaches(getUseCaches());
- jarFile=c.getJarFile();
+ jar_file=c.getJarFile();
+ close_jar_file = !getUseCaches();
}
catch(Exception e)
{
}
// Do we need to look more closely?
- if (jarFile!=null && _entry==null && !_directory)
+ if (jar_file!=null && _entry==null && !_directory)
{
// OK - we have a JarFile, lets look at the entries for our path
- Enumeration<JarEntry> e=jarFile.entries();
+ Enumeration<JarEntry> e=jar_file.entries();
while(e.hasMoreElements())
{
JarEntry entry = e.nextElement();
}
}
}
+
+ if(close_jar_file && jar_file!=null)
+ {
+ try
+ {
+ jar_file.close();
+ }
+ catch (IOException ioe)
+ {
+ LOG.ignore(ioe);
+ }
+ }
}
_exists= ( _directory || _entry!=null);