Fixed: HttpClient failed to return the error result

(OFBIZ-10281)

When you call the HttpClient on Rest API on url that return you an error, the HttpClient failed to give you the error stream:
    callResult = restClient.getStream();

If the flow is an error in the catch block with the line 
    in = con.getInputStream();
that return a FileNotFoundException

To solve if, if the connexion is an instance of HttpURLConnection we resolve this error inputStream contains the error message

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1827212 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nicolas Malin
2018-03-19 16:04:21 +00:00
parent 18cdc95263
commit 73bd798dda
@@ -537,6 +537,14 @@ public class HttpClient {
Debug.logWarning(ioe.getCause(), module);
return sendHttpRequestStream(method, true);
}
if ((con instanceof HttpURLConnection)) {
try {
in = ((HttpURLConnection) con).getErrorStream();
} catch (Exception ioerror) {
throw new HttpClientException("IO Error processing request", ioerror);
}
return in;
}
throw new HttpClientException("IO Error processing request", ioe);
} catch (RuntimeException e) {
throw e;