-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[CXF-7653]:Fix NPE in ClientProxy #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl | |
| } else { | ||
| result = invokeSync(method, oi, params); | ||
| } | ||
| if (result == null && !method.getReturnType().equals(Void.TYPE) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: you can use == to check class equality
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for review. @andrei-ivanov . I agree with you, == is more direct for class equality. |
||
| && method.getReturnType().isPrimitive()) { | ||
| throw new IllegalStateException("Response message did not contain proper response data"); | ||
| } | ||
| } catch (WebServiceException wex) { | ||
| throw wex; | ||
| } catch (Exception ex) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,9 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl | |
| } | ||
|
|
||
| Object o = invokeSync(method, oi, params); | ||
| if (o == null && !method.getReturnType().equals(Void.TYPE) && method.getReturnType().isPrimitive()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: you can use == to check class equality
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 . |
||
| throw new IllegalStateException("Response message did not contain proper response data"); | ||
| } | ||
| //call a virtual method passing the object. This causes the IBM JDK | ||
| //to keep the "this" pointer references and thus "this" doesn't get | ||
| //finalized in the midst of an invoke operation | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is all this code removed? If the WSDL states that there should be a response and there isn't, an exception should be thrown. The above is correct. By pushing some of this down into the ClientProxy's, anything that doesn't use the client proxies (like Camel endpoints) wouldn't have this check in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I ran reproducer EmptySoapBodyTest and found the NPE is thrown from Proxy class and root cause for this NPE is a null return value for a primitive type in InvocationHandler(ClientProxy), that's why I remove this and add this check in ClientProxy. I only looked at EmptySoapBodayTest , any other reproducer I need to have a look for CXF-7653 ?
Another reason why I remove these lines is this check doesn't work for this case: for example we have a simple wsdl which generates the following operation :
To work with Dispatch/Provider , a provider class created to simply return an empty StreamSource like:
The client dispatch expects receiving a null value. Add this check in ClientImpl throws IllegalStateException instead of return a null result.
For the caml endpoints without using the client proxy, it gets a null value result. Is the null value a problem for ClientCallback and something else ?