ok2c commented on code in PR #3328: URL: https://github.com/apache/httpcomponents-client/pull/3328#discussion_r4769942220
########## httpclient5/src/main/java/org/apache/hc/client5/http/RequestRetryStrategy.java: ########## @@ -0,0 +1,78 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + */ + +package org.apache.hc.client5.http; + +import java.io.IOException; +import java.util.Optional; + +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; +import org.apache.hc.core5.http.HttpRequest; +import org.apache.hc.core5.http.HttpResponse; +import org.apache.hc.core5.http.protocol.HttpContext; +import org.apache.hc.core5.util.TimeValue; + +/** + * Strategy interface to determine if the request should be retied in case + * of an i/o error or a 4xx or 5xx status response. + * + * @since 5.7 + */ +@Contract(threading = ThreadingBehavior.STATELESS) +public interface RequestRetryStrategy { + + /** + * Determines if a method should be retried after an I/O exception + * occurred during execution. + * + * @param request the request failed due to an I/O exception + * @param exception the exception that occurred + * @param execCount the number of times this method has been + * unsuccessfully executed + * @param context the context for the request execution + * + * @return {@code true} if the request should be retried, {@code false} + * otherwise + */ + Optional<TimeValue> retryRequest(HttpRequest request, IOException exception, int execCount, HttpContext context); + + /** + * Determines if a method should be retried given the response from + * the target server. + * + * @param response the response from the target server + * @param execCount the number of times this method has been + * unsuccessfully executed + * @param context the context for the request execution + * + * @return {@code true} if the request should be retried, {@code false} + * otherwise + */ Review Comment: @xcapdevila Corrected. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
