Skip to content

Commit 9e5dd13

Browse files
authored
Merge pull request #23 from EMCECS/bugfix-sdk-610
[SDK-610] add a new exception type to escape 4xx errors from server cooldowns
2 parents 7f13808 + 4410872 commit 9e5dd13

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.emc.rest.smart;
2+
3+
public class SmartClientException extends RuntimeException {
4+
5+
private ErrorType errorType = ErrorType.Unknown;
6+
7+
public SmartClientException(String message) {
8+
super(message);
9+
}
10+
11+
public SmartClientException(String message, Throwable cause) {
12+
super(message, cause);
13+
}
14+
public ErrorType getErrorType() {
15+
return errorType;
16+
}
17+
18+
public void setErrorType(ErrorType errorType) {
19+
this.errorType = errorType;
20+
}
21+
22+
public boolean isServerError() {
23+
return this.getErrorType().equals(SmartClientException.ErrorType.Service);
24+
}
25+
26+
public enum ErrorType {
27+
Client, // 4xx
28+
Service, // 5xx
29+
Unknown
30+
}
31+
32+
}

smart-client-jersey/src/main/java/com/emc/rest/smart/jersey/SmartFilter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.emc.rest.smart.jersey;
1717

1818
import com.emc.rest.smart.Host;
19+
import com.emc.rest.smart.SmartClientException;
1920
import com.emc.rest.smart.SmartConfig;
2021
import com.sun.jersey.api.client.ClientHandlerException;
2122
import com.sun.jersey.api.client.ClientRequest;
@@ -74,9 +75,9 @@ public ClientResponse handle(ClientRequest request) throws ClientHandlerExceptio
7475

7576
return response;
7677
} catch (RuntimeException e) {
77-
7878
// capture requests stats (error)
79-
host.callComplete(true);
79+
boolean isServerError = e instanceof SmartClientException && ((SmartClientException) e).isServerError();
80+
host.callComplete(isServerError);
8081
host.connectionClosed();
8182

8283
throw e;

0 commit comments

Comments
 (0)