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

HttpClient failed to return the error result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • Trunk
    • 18.12.01
    • framework
    • 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

            nmalin Nicolas Malin
            nmalin Nicolas Malin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: