From: jprocter Date: Tue, 18 Sep 2007 10:19:22 +0000 (+0000) Subject: added retry mechanism for opening of vamsas archives before it's assumed that the... X-Git-Tag: Release_0.2~49 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bae4dff034be3e157850f6e8888e25d694e3b21a;p=vamsas.git added retry mechanism for opening of vamsas archives before it's assumed that the archive contains no data. git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@471 be28352e-c001-0410-b1a7-c7978e42abec --- diff --git a/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java b/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java index 819be18..7f9a008 100644 --- a/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java +++ b/src/uk/ac/vamsas/client/simpleclient/VamsasArchiveReader.java @@ -30,6 +30,8 @@ import uk.ac.vamsas.objects.utils.document.VersionEntries; * */ public class VamsasArchiveReader { + private static final int JARFILE_OPEN_RETRIES = 50; + private static final int JARFILE_OPEN_RETRYWAIT = 1; private static Log log = LogFactory.getLog(VamsasArchiveReader.class); JarFile jfile=null; boolean stream=false; // true if we are seeking on the stream. @@ -70,16 +72,27 @@ public class VamsasArchiveReader { public VamsasArchiveReader(File vamsasfile) { jfile=null; + int retries=JARFILE_OPEN_RETRIES; + Exception ex=null; if (vamsasfile.exists()) { + while (jfile==null && --retries>0) + { try { jfile=new JarFile(vamsasfile); } catch (Exception e) { - log.debug("non-serious? couldn't open new JarFile on "+vamsasfile,e); + ex = e; jfile=null; + try { + Thread.sleep(JARFILE_OPEN_RETRYWAIT); + } catch (Exception w) {}; + } + } + if (jfile==null && ex!=null) + { + log.debug("non-serious? Exceptions when opening JarFile at "+vamsasfile,ex); } } - } /** * in an ideal world - this constructor will create a reader object