tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kean Erickson (Jira)" <j...@apache.org>
Subject [jira] [Created] (TOMEE-2693) When there is an exception during JAXB marshaling, an incomplete response is sent with a 200 code
Date Fri, 27 Sep 2019 22:39:00 GMT
Kean Erickson created TOMEE-2693:
------------------------------------

             Summary: When there is an exception during JAXB marshaling, an incomplete response
is sent with a 200 code
                 Key: TOMEE-2693
                 URL: https://issues.apache.org/jira/browse/TOMEE-2693
             Project: TomEE
          Issue Type: Bug
          Components: TomEE Build
    Affects Versions: 7.1.1
            Reporter: Kean Erickson


In the code below, the line "for (String s : stuffs)" creates an NPE, but the problem is that
the response is sent back with as a 200 and a clipped body.. which is simply "[{". It stopped
generating the response body when the property getter method was hit. A non-200 series code
should be sent.


 This error is shown in log when this happens:

24-Sep-2019 16:42:53.779 SEVERE [ouc5] org.apache.cxf.jaxrs.utils.JAXRSUtils.logMessageHandlerProblem
Problem with writing the data, class java.util.ArrayList, ContentType: application/json

Workaround: fix the NPE

My resource:
{code:java}
    @GET
    @ApiOperation(value = "Get stuff")
    @Produces(MediaType.APPLICATION_JSON)
    public List<TestDO> list(@Context HttpServletResponse response) {
        TestDO stuff = new TestDO();
        stuff.setId(1);

        List<TestDO> things = new ArrayList<>();
        things.add(stuff);        
        return things;
    }{code}
 
{code:java}
@XmlRootElement(name = "Test")
@XmlAccessorType(XmlAccessType.FIELD)
@ApiModel(value = "Test", description = "Test object")
public class TestDO {

    private int id;
    private List<String> stuffs = null;

    /**
     * Empty constructor, required by JAXB.
     */
    public TestDO() {
    }

    public TestDO(int id, String stuffs) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public List<String> getStuffs() {
        for (String s : stuffs)
            System.out.println(s);
        return stuffs;
    }

    public void setStuffs(List<String> stuffs) {
        this.stuffs = null;
    }

}
 {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message