You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would it be possible to remove the final modifier from HttpBackOffUnsuccessfulResponseHandler#handleResponse [1] so it lets a chance to log or trigger something? (without having to rewrite it) HttpBackOffIOExceptionHandler [2] does not have the final modifier for instance.
I've an SDK that communicates with my system. The client don't have to handle the HttpRequest directly, but still can he define a timeout+retry strategy (simple, exponential, etc). So I supply the base object (HttpRetryStrategy) in which 2 events can be fired (one by HBOURH#handleResponse, one by HBOIOEH#handleIOException), up to him to log or do whatever he wants
I don't need to have members changed to protected (it actually forces me to call super return super.handleResponse(request, response, supportsRetry); preventing any misbehavior)
I've something like this, works great so far:
request.setReadTimeout(this.httpRetryStrategy.getReadTimeout());
request.setNumberOfRetries(this.httpRetryStrategy.getNumberOfRetries());
/** one BackOff per request, but same is used for both unsuccessful-response and io-exception */
final BackOff backOff = this.httpRetryStrategy.newBackOff();
if (backOff != null) {
request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(backOff) {
@Override
public boolean handleResponse(HttpRequest request, HttpResponse response, boolean supportsRetry) throws IOException {
httpRetryStrategy.onFailure(request, response, supportsRetry);
return super.handleResponse(request, response, supportsRetry);
}
};
request.setIOExceptionHandler(new HttpBackOffIOExceptionHandler(backOff) {
@Override
public boolean handleIOException(HttpRequest request, boolean supportsRetry) throws IOException {
httpRetryStrategy.onException(request, supportsRetry);
return super.handleIOException(request, supportsRetry);
}
});
}
Activity
chingor13 commentedon Dec 28, 2018
Can you describe the type of logging you want to add? Perhaps, we could instrument this for everyone.
Removing final wouldn't do much unless we also change all the members to protected.
sebfz1 commentedon Dec 28, 2018
I've an SDK that communicates with my system. The client don't have to handle the
HttpRequestdirectly, but still can he define a timeout+retry strategy (simple, exponential, etc). So I supply the base object (HttpRetryStrategy) in which 2 events can be fired (one byHBOURH#handleResponse, one byHBOIOEH#handleIOException), up to him to log or do whatever he wantsI don't need to have members changed to protected (it actually forces me to call super
return super.handleResponse(request, response, supportsRetry);preventing any misbehavior)I've something like this, works great so far:
sebfz1 commentedon Jan 8, 2019
Great, thanks a lot! 👍