Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 17CBF200C01 for ; Thu, 19 Jan 2017 08:29:39 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 164E2160B54; Thu, 19 Jan 2017 07:29:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 435F1160B42 for ; Thu, 19 Jan 2017 08:29:38 +0100 (CET) Received: (qmail 25097 invoked by uid 500); 19 Jan 2017 07:29:32 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 25085 invoked by uid 99); 19 Jan 2017 07:29:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jan 2017 07:29:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id DCBDBC1A83 for ; Thu, 19 Jan 2017 07:29:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id T7WcvLkNX1tt for ; Thu, 19 Jan 2017 07:29:30 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 2880D5FB79 for ; Thu, 19 Jan 2017 07:29:30 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 9CCDCE865D for ; Thu, 19 Jan 2017 07:29:28 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4ED6625289 for ; Thu, 19 Jan 2017 07:29:27 +0000 (UTC) Date: Thu, 19 Jan 2017 07:29:27 +0000 (UTC) From: "Freeman Fang (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CXF-5436) Poorly crafted response caused NullPointerException when processing incoming message MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 19 Jan 2017 07:29:39 -0000 [ https://issues.apache.org/jira/browse/CXF-5436?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Freeman Fang updated CXF-5436: ------------------------------ Fix Version/s: 3.0.13 3.1.10 3.2.0 > Poorly crafted response caused NullPointerException when processing incoming message > ------------------------------------------------------------------------------------ > > Key: CXF-5436 > URL: https://issues.apache.org/jira/browse/CXF-5436 > Project: CXF > Issue Type: Bug > Components: JAX-WS Runtime > Reporter: Kyle Lape > Assignee: Freeman Fang > Fix For: 3.2.0, 3.1.10, 3.0.13 > > > A CXF SOAP client is processing a response, and it gets a NPE: > {noformat} > 2013-11-26 10:03:39,462 243006 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (pool-38-thread-1:) Interceptor for {http://REDACTED has thrown exception, unwinding now > java.lang.NullPointerException > at org.apache.cxf.staxutils.StaxUtils.toNextElement(StaxUtils.java:333) > at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:80) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:755) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:2408) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:2278) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:2121) > at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) > at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:695) > at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:243) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) > at $Proxy1346.tenprintSearchResponse(Unknown Source) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) > at java.lang.reflect.Method.invoke(Unknown Source) > at my.application.ClassName.run(MessageRouterTask.java:44) > at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) > at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) > at java.util.concurrent.FutureTask.run(Unknown Source) > at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) > at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) > at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) > at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) > at java.lang.Thread.run(Unknown Source) > {noformat} > The issue has been traced back to the {{StaxInInterceptor}} around this code: > {code:java} > if (contentType == null) { > //if contentType is null, this is likely a an empty post/put/delete/similar, lets see if it's > //detectable at all > Map> m = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS)); > if (m != null) { > List contentLen = HttpHeaderHelper > .getHeader(m, HttpHeaderHelper.CONTENT_LENGTH); > List contentTE = HttpHeaderHelper > .getHeader(m, HttpHeaderHelper.CONTENT_TRANSFER_ENCODING); > if ((StringUtils.isEmpty(contentLen) || "0".equals(contentLen.get(0))) > && StringUtils.isEmpty(contentTE)) { > return; > } > } > } > {code} > The endpoint is responding with an empty {{Content-Type}} header and is using chunked encoding, so it's setting the {{Transfer-Encoding}} header and omitting the {{Content-Length}} header. These combined attributes cause the {{StaxInInterceptor}} to return before the {{XMLStreamReader}} is created and put in the {{Message}}, causing the NPE down the chain. While I certainly feel that the endpoint shouldn't respond in such a way, the NPE in CXF is probably not the best way to handle this odd response from the endpoint. -- This message was sent by Atlassian JIRA (v6.3.4#6332)