Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-633

RESTEasy ClientInvoker throws generic RuntimeExceptions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 3.0-beta-1, 2.3.5.Final
    • 2.0.GA, 2.0.1.GA, 2.1.0.GA, 2.2.1, 2.2.2.GA, 2.2.3.GA
    • jaxrs
    • None

      The invoke() method of the ClientInvoker class catches all Exceptions thrown by the underlying connection library (e.g., org.apache.http.conn.HttpHostConnectException, which is thrown when the remote host is not accepting connections) and wraps them in generic RuntimeExceptions. This is highly undesirable, as it forces the caller to "catch (RuntimeException)" (catching NPE's and other non-connection-related exceptions in the process) just to be able to react to connection problems. A more specific unchecked exception should be thrown instead so that the caller can distinguish between RuntimeExceptions caused by bugs in the code from mere connection issues.

      Additionally, the invoke() method also throws a generic RuntimeException if the object was constructed with a null value for baseUri. It would be far better to detect the null baseUri in ProxyFactory.create() and throw a NullPointerException before the ClientInvoker is even created, so that the root cause of the problem can be easily identified (rather than result in a generic error at a potentially much later time in the execution of the program).

              rsigal@redhat.com Ronald Sigal
              reggert_jira Richard Eggert (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: