You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ofbiz.apache.org by "Nicolas Malin (JIRA)" <ji...@apache.org> on 2018/03/14 10:54:00 UTC

[jira] [Created] (OFBIZ-10281) HttpClient failed to return the error result

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

{code}
return a FileNotFoundException

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



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)