-
Enhancement
-
Resolution: Done
-
Major
-
2.0.GA, 2.0.1.GA, 2.1.0.GA, 2.2.1, 2.2.2.GA, 2.2.3.GA
-
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).