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:55:00 UTC

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

     [ https://issues.apache.org/jira/browse/OFBIZ-10281?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nicolas Malin updated OFBIZ-10281:
----------------------------------
    Attachment: OFBIZ-10281.patch

> 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
>            Priority: Minor
>         Attachments: OFBIZ-10281.patch
>
>
> 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)