347130 Empty getResourcePaths due to ZipFileClosedException
This commit is contained in:
parent
c7c4c6e13b
commit
4d889de159
|
@ -19,6 +19,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
|
@ -108,7 +109,7 @@ class JarFileResource extends JarResource
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Returns true if the respresenetd resource exists.
|
||||
* Returns true if the represented resource exists.
|
||||
*/
|
||||
@Override
|
||||
public boolean exists()
|
||||
|
@ -240,13 +241,43 @@ class JarFileResource extends JarResource
|
|||
@Override
|
||||
public synchronized String[] list()
|
||||
{
|
||||
|
||||
if (isDirectory() && _list==null)
|
||||
{
|
||||
ArrayList list = new ArrayList(32);
|
||||
List<String> list = null;
|
||||
try
|
||||
{
|
||||
list = listEntries();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//Sun's JarURLConnection impl for jar: protocol will close a JarFile in its connect() method if
|
||||
//useCaches == false (eg someone called URLConnection with defaultUseCaches==true).
|
||||
//As their sun.net.www.protocol.jar package caches JarFiles and/or connections, we can wind up in
|
||||
//the situation where the JarFile we have remembered in our _jarFile member has actually been closed
|
||||
//by other code.
|
||||
//So, do one retry to drop a connection and get a fresh JarFile
|
||||
LOG.warn("Retrying list:"+e);
|
||||
LOG.debug(e);
|
||||
release();
|
||||
list = listEntries();
|
||||
}
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
_list=new String[list.size()];
|
||||
list.toArray(_list);
|
||||
}
|
||||
}
|
||||
return _list;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private List<String> listEntries ()
|
||||
{
|
||||
checkConnection();
|
||||
|
||||
ArrayList<String> list = new ArrayList<String>(32);
|
||||
JarFile jarFile=_jarFile;
|
||||
if(jarFile==null)
|
||||
{
|
||||
|
@ -258,6 +289,8 @@ class JarFileResource extends JarResource
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
||||
e.printStackTrace();
|
||||
LOG.ignore(e);
|
||||
}
|
||||
}
|
||||
|
@ -295,12 +328,13 @@ class JarFileResource extends JarResource
|
|||
list.add(listName);
|
||||
}
|
||||
|
||||
_list=new String[list.size()];
|
||||
list.toArray(_list);
|
||||
}
|
||||
return _list;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Return the length of the resource
|
||||
|
|
Loading…
Reference in New Issue