Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8EEB61187F for ; Thu, 14 Aug 2014 11:40:12 +0000 (UTC) Received: (qmail 84295 invoked by uid 500); 14 Aug 2014 11:40:12 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 84271 invoked by uid 500); 14 Aug 2014 11:40:12 -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 84254 invoked by uid 99); 14 Aug 2014 11:40:11 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Aug 2014 11:40:11 +0000 Date: Thu, 14 Aug 2014 11:40:11 +0000 (UTC) From: "Sergey Beryozkin (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CXF-5795) Reading the entity from a Response with 202 - Accepted causes NullPointerException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14096879#comment-14096879 ] Sergey Beryozkin commented on CXF-5795: --------------------------------------- I've added a test confirming it works: http://git-wip-us.apache.org/repos/asf/cxf/commit/91f89e48 but only if a WebClient sets a contextual property "org.apache.cxf.transport.processOneWayResponse" to true. At the moment it is disabled by default and HttpConduit resets InputStream to null. I believe it is the *optimization* related to the use of WS-RM in scope of working with SOAP services but it would make sense even for HTTP clients thinking they post one way requests. 202 is very often associated with one way requests, it's a bit unusual to have the entity returned as part of the regular HTTP responses. I've reopened this JIRA because may be I can set this property to true by default if the client does not set a oneway exchange property. > Reading the entity from a Response with 202 - Accepted causes NullPointerException > ---------------------------------------------------------------------------------- > > Key: CXF-5795 > URL: https://issues.apache.org/jira/browse/CXF-5795 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 2.7.11 > Environment: Apache CXF 2.7.11 > Reporter: Daniel Peder Dahlsveen > Assignee: Sergey Beryozkin > Fix For: 2.7.12, 3.0.1 > > Attachments: cxf-demo.zip > > > The entity of a Response with HTTP status code 202 - Accepted is null. This causes a NullPointerException when calling response.readEntity(). Furthermore, this bug seems to only occur when using the JAXRSClientFactory, and it was introduced in CXF 2.7.11. > The stacktrace is of the NullPointerException: > java.lang.NullPointerException > at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:345) > at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:286) > at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:276) > To recreate the bug do the following: > Create a REST service that returns a 202 - Accepted with a non-null entity. In our case, the service was for HTTP POST. > Create a unit test that tests the service by creating a client with the JAXRSClientFactory and then reads the entity from the response. > Both return Response.accepted(entity).build(); and return Response.status(Response.Status.ACCEPTED).entity(entity).build(); causes the bug. -- This message was sent by Atlassian JIRA (v6.2#6252)