The recurring pattern seems to be... ResultType methodName(ArgType args) throws ExceptionType { int trialsSoFar = 0; long maxTime = System.currentTimeMillis() + maxTotalDelay; Exception error = null; while (waitAgain(maxTime, trialsSoFar++, error)) { try { return super.methodName(args); } catch (ExceptionType e) { error = e; } } return super.methodName(args); }
...where the waitAgain method seems to take in more args then it really needs (error is completley unused, and trialsSoFar is only need to know if we are on the first trial) There may be a subltety i'm missing here, but it seems like this might be more clearly (and susinctly) expressed with something like... ResultType methodName(ArgType args) throws ExceptionType { long maxTime = System.currentTimeMillis() + maxTotalDelay; while (true) { try { return super.methodName(args); } catch (ExceptionType e) { if (maxTime < System.currentTimeMillis()) throw e } wait(maxTime); } } ...where the wait method also get's simpler... static void wait(long maxTime) long moreTime = maxTime - System.currentTimeMillis(); long delay = Math.min(moreTime, intervalDelay); try { Thread.sleep(delay); } catch (InterruptedException e1) { /* NOOP */ } } ...but i haven't tried this, and as i said: there may be some subltety of your approach that i'm missing. -Hoss --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]