Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-10281

HttpClient failed to return the error result

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Trunk
    • Fix Version/s: Upcoming Branch
    • Component/s: framework
    • Labels:
      None

      Description

      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 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

        Attachments

        1. OFBIZ-10281.patch
          1.0 kB
          Nicolas Malin

          Activity

            People

            • Assignee:
              soledad Nicolas Malin
              Reporter:
              soledad Nicolas Malin
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: