[ https://issues.apache.org/jira/browse/CXF-7653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16464031#comment-16464031 ]
ASF GitHub Bot commented on CXF-7653: ------------------------------------- jimma closed pull request #414: [CXF-7653]:Fix NPE in ClientProxy URL: https://github.com/apache/cxf/pull/414 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java index 799c26e0593..1cd330a8be9 100644 --- a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java +++ b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java @@ -657,24 +657,9 @@ private void enrichFault(Fault fault) { if (ex != null) { throw ex; } - - if (resList == null - && oi != null && !oi.getOperationInfo().isOneWay()) { - - BindingOperationInfo boi = oi; - if (boi.isUnwrapped()) { - boi = boi.getWrappedOperation(); - } - if (!boi.getOutput().getMessageParts().isEmpty()) { - //we were supposed to get some output, but didn't - throw new IllegalStateException("Response message did not contain proper response data. Expected: " - + boi.getOutput().getMessageParts().get(0).getConcreteName()); - } - } if (resList != null) { return resList.toArray(); } - return null; } protected Exception getException(Exchange exchange) { diff --git a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java index 5048af1818c..d89be942a84 100644 --- a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java +++ b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java @@ -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) + && method.getReturnType().isPrimitive()) { + throw new IllegalStateException("Response message did not contain proper response data"); + } } catch (WebServiceException wex) { throw wex; } catch (Exception ex) { diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java index d0670ca4031..2fb7bb65e47 100644 --- a/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java +++ b/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxy.java @@ -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()) { + 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 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Null pointer in JaxwsResponseCallback > ------------------------------------- > > Key: CXF-7653 > URL: https://issues.apache.org/jira/browse/CXF-7653 > Project: CXF > Issue Type: Bug > Components: JAX-WS Runtime > Affects Versions: 3.0.10 > Environment: AIX > Reporter: Neal Johnson > Assignee: Daniel Kulp > Priority: Major > Fix For: 3.1.15, 3.2.3, 3.2.4 > > > Occasionally we'll get a null pointer in the JAXWS code. > Caused by: java.lang.NullPointerException > at > org.apache.cxf.jaxws.JaxwsResponseCallback.get(JaxwsResponseCallback.java:49) > When we receive a SOAP message with an empty body (example below) the > (T)callback.get()[0] line in JaxwsResponseCallback throws a null pointer > exception. We're still unsure why we're getting a message with an empty body > in the first place, and if that's AIX related or we're just lucky in other > operating systems. > {{<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">}} > {{ <soap:Header>}} > {{ <!-- Stuff in here that I've removed. -->}} > {{ </soap:Header>}} > {{ <soap:Body />}} > {{</soap:Envelope>}} > We did some debugging and checked where our code diverged between the two > types of messages. The below chunk of code is where it starts to unravel. > {code:java|title=Code from within > DocLiteralInInterceptor.java|borderStyle=solid} > MessageContentsList parameters = new MessageContentsList(); > Exchange exchange = message.getExchange(); > BindingOperationInfo bop = exchange.getBindingOperationInfo(); > boolean client = isRequestor(message); > //if body is empty and we have BindingOperationInfo, we do not need to match > //operation anymore, just return > if (bop != null && !StaxUtils.toNextElement(xmlReader)) { > // body may be empty for partial response to decoupled request > return; > } > ... > // Lots of logic > ... > message.setContent(List.class, parameters); > {code} > ~~~~~~~ > When we do a StaxUtils.toNextElement that returns false, as it hits the end > of the body immediately. This causes it to return without setting the > MessageContentsList as a list on the message. Later, when the code tries to > do a .getContent(List) it doesn't find anything, and this leads to it setting > null as the first element returned on callback.get()[0]. -- This message was sent by Atlassian JIRA (v7.6.3#76005)