|
20 | 20 | import org.jboss.resteasy.reactive.common.jaxrs.StatusTypeImpl; |
21 | 21 |
|
22 | 22 | /** |
23 | | - * Subclass of {@link WebApplicationException} for use by clients. |
| 23 | + * Subclass of {@link WebApplicationException} for use by clients, which forbids setting a response that |
| 24 | + * would be used by the server. |
| 25 | + * FIXME: I'd rather this be disjoint from WebApplicationException, but changing the exception type could break existing |
| 26 | + * clients catching this exception. |
24 | 27 | */ |
25 | 28 | @SuppressWarnings("serial") |
26 | 29 | public class WebClientApplicationException extends WebApplicationException implements ResteasyReactiveClientProblem { |
27 | 30 |
|
| 31 | + /** |
| 32 | + * The response received by the client after making the request. |
| 33 | + * Saved in an alternate field to prevent it from being used by the server. |
| 34 | + */ |
| 35 | + private final transient Response clientResponse; |
| 36 | + |
28 | 37 | public WebClientApplicationException(int responseStatus) { |
29 | 38 | this(responseStatus, (String) null); |
30 | 39 | } |
31 | 40 |
|
32 | 41 | public WebClientApplicationException(int responseStatus, String responseReasonPhrase) { |
33 | 42 | super("Server response is: " + responseStatus, null, new DummyResponse(responseStatus, responseReasonPhrase)); |
| 43 | + this.clientResponse = getResponse(); |
| 44 | + } |
| 45 | + |
| 46 | + public WebClientApplicationException(Response clientResponse) { |
| 47 | + super("Server response is: " + clientResponse.getStatus(), new DummyResponse(clientResponse.getStatus(), |
| 48 | + clientResponse.getStatusInfo().getReasonPhrase())); |
| 49 | + this.clientResponse = clientResponse; |
34 | 50 | } |
35 | 51 |
|
36 | | - public WebClientApplicationException(int responseStatus, Response response) { |
37 | | - super("Server response is: " + responseStatus, response); |
| 52 | + public WebClientApplicationException(Throwable cause, Response clientResponse) { |
| 53 | + super("Server response is: " + clientResponse.getStatus(), cause, new DummyResponse(clientResponse.getStatus(), |
| 54 | + clientResponse.getStatusInfo().getReasonPhrase())); |
| 55 | + this.clientResponse = clientResponse; |
38 | 56 | } |
39 | 57 |
|
40 | | - public WebClientApplicationException(int responseStatus, Throwable cause, Response response) { |
41 | | - super("Server response is: " + responseStatus, cause, response); |
| 58 | + public Response getClientResponse() { |
| 59 | + return clientResponse; |
42 | 60 | } |
43 | 61 |
|
44 | 62 | /** |
|
0 commit comments