Skip to content

Commit

Permalink
fix callcomplete: reset consecutiveErrors when 4xx
Browse files Browse the repository at this point in the history
  • Loading branch information
dunedodo committed Sep 15, 2022
1 parent a5ccbf2 commit 71434dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

public class SmartClientException extends RuntimeException {

private ErrorType errorType = ErrorType.Unknown;

public SmartClientException(String message) {
super(message);
}

public SmartClientException(String message, Throwable cause) {
super(message, cause);
}

public enum ErrorType {
Client, // 4xx
Service, // 5xx
Unknown
}

public ErrorType getErrorType() {
return errorType;
}
Expand All @@ -24,6 +19,14 @@ public void setErrorType(ErrorType errorType) {
this.errorType = errorType;
}

private ErrorType errorType = ErrorType.Unknown;
public enum ErrorType {
Client, // 4xx
Service, // 5xx
Unknown
}

public boolean isServerError() {
return this.getErrorType().equals(SmartClientException.ErrorType.Service);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio

return response;
} catch (RuntimeException e) {

if (e instanceof SmartClientException && !((SmartClientException)e).getErrorType().equals(SmartClientException.ErrorType.Client)) {
// capture requests stats (error)
host.callComplete(true);
host.connectionClosed();
}
// capture requests stats (error)
boolean isServerError = e instanceof SmartClientException && ((SmartClientException) e).isServerError();
host.callComplete(isServerError);
host.connectionClosed();

throw e;
}
Expand Down

0 comments on commit 71434dc

Please sign in to comment.