public void execute(SPFSession session, FutureSPFResult result, boolean throttle) { SPFChecker checker; while ((checker = session.popChecker()) != null) { // only execute checkers we added (better recursivity) log.debug("Executing checker: " + checker); try { DNSLookupContinuation cont = checker.checkSPF(session); // if the checker returns a continuation we return it if (cont != null) { invokeAsynchService(session, result, cont, throttle); return; } } catch (Exception e) { while (e != null) { while (checker == null || !(checker instanceof SPFCheckerExceptionCatcher)) { checker = session.popChecker(); } try { ((SPFCheckerExceptionCatcher) checker).onException(e, session); e = null; } catch (SPFResultException ex) { e = ex; } finally { checker = null; } } } } result.setSPFResult(session); }
public void run() { while (true) { IResponse resp = responseQueue.removeResponse(); Integer respId = (Integer) resp.getId(); SPFSession session = sessions.remove(respId); FutureSPFResult result = results.remove(respId); DNSLookupContinuation cont = (DNSLookupContinuation) session.getAttribute(ATTRIBUTE_STAGED_EXECUTOR_CONTINUATION); DNSResponse response; if (resp.getException() != null) { response = new DNSResponse((TimeoutException) resp.getException()); } else { response = new DNSResponse(resp.getValue()); } try { cont = cont.getListener().onDNSResponse(response, session); if (cont != null) { invokeAsynchService(session, result, cont, false); } else { execute(session, result, false); } } catch (Exception e) { SPFChecker checker = null; while (e != null) { while (checker == null || !(checker instanceof SPFCheckerExceptionCatcher)) { checker = session.popChecker(); } try { ((SPFCheckerExceptionCatcher) checker).onException(e, session); e = null; } catch (SPFResultException ex) { e = ex; } finally { checker = null; } } execute(session, result, false); } } }