[
https://issues.apache.org/jira/browse/TOMEE-2693?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Richard Zowalla closed TOMEE-2693.
----------------------------------
Resolution: Cannot Reproduce
Closing: reported against TomEE 7.x (end of life) and not confirmed on current
versions. Please reopen or file a new issue if this still happens on TomEE 10.x
or later.
> 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
> Priority: Minor
>
> 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}
>
> My data object:
> {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.20.10#820010)