cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CXF-6060) Calling readEntity() on Response created by Response.build() causes NullPointerException
Date Tue, 28 Oct 2014 17:41:33 GMT

     [ https://issues.apache.org/jira/browse/CXF-6060?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sergey Beryozkin resolved CXF-6060.
-----------------------------------
       Resolution: Fixed
    Fix Version/s: 3.0.3
                   3.1.0
         Assignee: Sergey Beryozkin

> Calling readEntity() on Response created by Response.build() causes NullPointerException
> ----------------------------------------------------------------------------------------
>
>                 Key: CXF-6060
>                 URL: https://issues.apache.org/jira/browse/CXF-6060
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.0.1
>         Environment: Ubuntu 14.04.1 LTS, x86_64.
> java version "1.8.0_25"
> Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
>            Reporter: Nikolai Amelichev
>            Assignee: Sergey Beryozkin
>             Fix For: 3.1.0, 3.0.3
>
>
> This small test:
> {code:java}
> @Test
> public void should_read_entity() {
>     final String str = "ouch";
>     Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
>               .entity(str)
>               .build();
>     Assert.assertEquals(str, response.readEntity(String.class));
> }
> {code}
> unexpectedly throws `NullPointerException` with the following stacktrace:
> {noformat}
> at org.apache.cxf.jaxrs.provider.ProviderFactory.getInstance(ProviderFactory.java:950)
> at org.apache.cxf.jaxrs.impl.ResponseImpl.doReadEntity(ResponseImpl.java:357)
> at org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:319)
> at
> org.apache.cxf.jaxrs.impl.ResponseImpl.readEntity(ResponseImpl.java:309)
> {noformat}
> (because {{Response}} created by {{Response.build()}} has {{outMessage == null}}).
> JAX-RS specifies that {{Response.readEntity()}} throws only {{ProcessingException}} and
{{IllegalStateException}}. None of them apply: response entity can be converted to {{String}},
and response is not closed. So this test should pass (with {{Response.readEntity()}} returning
{{"ouch"}}).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message