Number of retries = 3 The total duration of all attempts doesn't exceed 10 seconds.
int result = -1; int attempts = 0; int duration = 0; while (attempts < 3 && duration <= 10) { try { result = action.execute(); break; } catch (Exception e) { duration += action.getDuration(); attempts++; } }