ofbiz-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicolas Malin (JIRA)" <j...@apache.org>
Subject [jira] [Created] (OFBIZ-10281) HttpClient failed to return the error result
Date Wed, 14 Mar 2018 10:54:00 GMT
Nicolas Malin created OFBIZ-10281:

             Summary: HttpClient failed to return the error result
                 Key: OFBIZ-10281
                 URL: https://issues.apache.org/jira/browse/OFBIZ-10281
             Project: OFBiz
          Issue Type: Bug
          Components: framework
    Affects Versions: Trunk
            Reporter: Nicolas Malin
            Assignee: Nicolas Malin

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();{code}
If the flow is an error you have HttpClient:534
in = con.getInputStream();

return a FileNotFoundException

To solve this I catch the error and restart the connexion like this
if ((con instanceof HttpURLConnection)) {
    try {
        in = ((HttpURLConnection) con).getErrorStream();
    } catch (Exception ioerror) {
        throw new HttpClientException("IO Error processing request", ioerror);
    return in;
With this the inputStream contains the error message and we can use it for end user return

This message was sent by Atlassian JIRA

View raw message