All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.hermes.client.HermesClientBasicRetryCondition Maven / Gradle / Ivy

The newest version!
package pl.allegro.tech.hermes.client;

import static java.net.HttpURLConnection.HTTP_CLIENT_TIMEOUT;

import java.util.function.Predicate;

public class HermesClientBasicRetryCondition implements Predicate {
  @Override
  public boolean test(HermesResponse response) {
    return response == null
        || (isClientTimeoutOrServerError(response) || isFailedExceptionally(response));
  }

  private boolean isClientTimeoutOrServerError(HermesResponse response) {
    return response.getHttpStatus() == HTTP_CLIENT_TIMEOUT || response.getHttpStatus() / 100 == 5;
  }

  private boolean isFailedExceptionally(HermesResponse response) {
    return response.isFailure() && response.getFailureCause().isPresent();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy