Skip to content

Commit 71e205f

Browse files
committed
Revert "Provide access to the status code returned by the most recent web service proxy invocation."
This reverts commit 1689c6b.
1 parent 1689c6b commit 71e205f

File tree

2 files changed

+6
-28
lines changed

2 files changed

+6
-28
lines changed

httprpc-client/src/main/java/org/httprpc/WebServiceProxy.java

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ public interface ErrorHandler {
137137

138138
private String multipartBoundary = UUID.randomUUID().toString();
139139

140-
private int statusCode = -1;
141-
142140
private static final String UTF_8 = "UTF-8";
143141

144142
private static final int EOF = -1;
@@ -591,13 +589,13 @@ public void encodeRequest(OutputStream outputStream) throws IOException {
591589
}
592590

593591
// Read response
594-
statusCode = connection.getResponseCode();
592+
int responseCode = connection.getResponseCode();
595593

596594
String contentType = connection.getContentType();
597595

598596
T result;
599-
if (statusCode / 100 == 2) {
600-
if (statusCode % 100 < 4) {
597+
if (responseCode / 100 == 2) {
598+
if (responseCode % 100 < 4) {
601599
try (InputStream inputStream = connection.getInputStream()) {
602600
result = responseHandler.decodeResponse(inputStream, contentType);
603601
}
@@ -612,7 +610,7 @@ public void encodeRequest(OutputStream outputStream) throws IOException {
612610
}
613611

614612
try (InputStream inputStream = connection.getErrorStream()) {
615-
errorHandler.handleResponse(inputStream, contentType, statusCode);
613+
errorHandler.handleResponse(inputStream, contentType, responseCode);
616614
}
617615

618616
return null;
@@ -727,17 +725,6 @@ private static Object getParameterValue(Object argument) {
727725
}
728726
}
729727

730-
/**
731-
* Returns the status code produced by the most recent invocation.
732-
*
733-
* @return
734-
* The status code produced by the most recent invocation, or
735-
* <code>-1</code> if the proxy has never been invoked.
736-
*/
737-
public int getStatusCode() {
738-
return statusCode;
739-
}
740-
741728
/**
742729
* Creates a web service proxy representing a GET request.
743730
*

httprpc-test/src/test/java/org/httprpc/WebServiceProxyTest.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,7 @@ public void testError() throws IOException {
411411

412412
fail();
413413
} catch (WebServiceException exception) {
414-
assertNotNull(exception.getMessage());
415-
assertEquals(500, exception.getStatusCode());
414+
assertTrue(true);
416415
}
417416
}
418417

@@ -497,21 +496,13 @@ private List<Size> getCatalogSizes() throws IOException {
497496
}
498497

499498
@Test
500-
public void testCustomErrorHandler() throws IOException {
499+
public void testCustomException() throws IOException {
501500
WebServiceProxy webServiceProxy = new WebServiceProxy("GET", new URL(baseURL, "test/error"));
502501

503502
webServiceProxy.setErrorHandler((errorStream, contentType, statusCode) -> {
504503
throw new CustomException();
505504
});
506505

507506
assertThrows(CustomException.class, webServiceProxy::invoke);
508-
509-
webServiceProxy.setErrorHandler((errorStream, contentType, statusCode) -> {
510-
// No-op
511-
});
512-
513-
webServiceProxy.invoke();
514-
515-
assertEquals(500, webServiceProxy.getStatusCode());
516507
}
517508
}

0 commit comments

Comments
 (0)