@Test public void failOnNull() { TransmissionPolicyManager tpm = new TransmissionPolicyManager(true); TransmissionHandlerArgs args = new TransmissionHandlerArgs(); ErrorHandler eh = new ErrorHandler(tpm); boolean result = eh.validateTransmissionAndSend(args); Assert.assertFalse(result); }
boolean validateTransmissionAndSend(TransmissionHandlerArgs args) { if (args.getTransmission() != null && args.getTransmissionDispatcher() != null) { args.getTransmission().incrementNumberOfSends(); switch (args.getResponseCode()) { case TransmissionSendResult.REQUEST_TIMEOUT: case TransmissionSendResult.INTERNAL_SERVER_ERROR: case TransmissionSendResult.SERVICE_UNAVAILABLE: case TransmissionSendResult.CLIENT_SIDE_EXCEPTION: backoffAndSendTransmission(args); return true; default: logger.trace("Http response code {} not handled by {}", args.getResponseCode(), this.getClass().getName()); return false; } } else if (args.getException() != null) { backoffAndSendTransmission(args); return true; } return false; }
ErrorHandler implements TransmissionHandler { boolean validateTransmissionAndSend(TransmissionHandlerArgs args) { if (args.getTransmission() != null && args.getTransmissionDispatcher() != null) { args.getTransmission().incrementNumberOfSends(); switch (args.getResponseCode()) { case TransmissionSendResult.REQUEST_TIMEOUT: case TransmissionSendResult.INTERNAL_SERVER_ERROR: case TransmissionSendResult.SERVICE_UNAVAILABLE: case TransmissionSendResult.CLIENT_SIDE_EXCEPTION: backoffAndSendTransmission(args); return true; default: logger.trace("Http response code {} not handled by {}", args.getResponseCode(), this.getClass().getName()); return false; } } else if (args.getException() != null) { backoffAndSendTransmission(args); return true; } return false; } }
ErrorHandler implements TransmissionHandler { boolean validateTransmissionAndSend(TransmissionHandlerArgs args) { if (args.getTransmission() != null && args.getTransmissionDispatcher() != null) { args.getTransmission().incrementNumberOfSends(); switch (args.getResponseCode()) { case TransmissionSendResult.REQUEST_TIMEOUT: case TransmissionSendResult.INTERNAL_SERVER_ERROR: case TransmissionSendResult.SERVICE_UNAVAILABLE: case TransmissionSendResult.CLIENT_SIDE_EXCEPTION: backoffAndSendTransmission(args); return true; default: logger.trace("Http response code {} not handled by {}", args.getResponseCode(), this.getClass().getName()); return false; } } else if (args.getException() != null) { backoffAndSendTransmission(args); return true; } return false; } ErrorHandler(TransmissionPolicyManager policy); }
ErrorHandler implements TransmissionHandler { boolean validateTransmissionAndSend(TransmissionHandlerArgs args) { if (args.getTransmission() != null && args.getTransmissionDispatcher() != null) { args.getTransmission().incrementNumberOfSends(); switch (args.getResponseCode()) { case TransmissionSendResult.REQUEST_TIMEOUT: case TransmissionSendResult.INTERNAL_SERVER_ERROR: case TransmissionSendResult.SERVICE_UNAVAILABLE: case TransmissionSendResult.CLIENT_SIDE_EXCEPTION: backoffAndSendTransmission(args); return true; default: logger.trace("Http response code {} not handled by {}", args.getResponseCode(), this.getClass().getName()); return false; } } else if (args.getException() != null) { backoffAndSendTransmission(args); return true; } return false; } ErrorHandler(TransmissionPolicyManager policy); @Override void onTransmissionSent(TransmissionHandlerArgs args); }
ErrorHandler implements TransmissionHandler { boolean validateTransmissionAndSend(TransmissionHandlerArgs args) { if (args.getTransmission() != null && args.getTransmissionDispatcher() != null) { args.getTransmission().incrementNumberOfSends(); switch (args.getResponseCode()) { case TransmissionSendResult.REQUEST_TIMEOUT: case TransmissionSendResult.INTERNAL_SERVER_ERROR: case TransmissionSendResult.SERVICE_UNAVAILABLE: case TransmissionSendResult.CLIENT_SIDE_EXCEPTION: backoffAndSendTransmission(args); return true; default: logger.trace("Http response code {} not handled by {}", args.getResponseCode(), this.getClass().getName()); return false; } } else if (args.getException() != null) { backoffAndSendTransmission(args); return true; } return false; } ErrorHandler(TransmissionPolicyManager policy); @Override void onTransmissionSent(TransmissionHandlerArgs args);  }