Hi Xilai

Apologies for a delay, I've lost this message but got it again thanks to Colm...

The best way to solve the issue is to return Response without setting an actual entity, example, "return Response.ok().build()".

Right now the provider throws IndexOutOfBoundsException which is a bug but I also think that the fix is to throw an exception because the multipart payload does have to have at least one part.

Cheers, Sergey



---------- Forwarded message ----------
From: *XiLai Dai* <[email protected] <mailto:[email protected]>>
Date: Wed, Aug 29, 2012 at 10:17 AM
Subject: No any Attachment will throw IndexOutOfBoundsException in
org.apache.cxf.jaxrs.ext.MessageContextImpl
To: "[email protected] <mailto:[email protected]>"
<[email protected] <mailto:[email protected]>>


Hi,

The WADL fragment :
<resource path="/abc/def">
<method name="GET" id="lookupABC">
                     ......
<response status="200">
<representation mediaType="multipart/mixed;type=application/xml" />
</response>
</method>
</resource>

And code in the implement class:

public Response lookupABC(String str) {
...
List<Attachment> atts = new LinkedList<Attachment>();
return Response.ok(new MultipartBody(atts, true)).build();
}

This exception will be thrown when atts.size() = 0. (no any attachment).
  After debug into the cxf code (2.6.2), on (line 189):
             Attachment root = (Attachment)handlers.get(0);
In the org.apache.cxf.jaxrs.ext.MessageContextImpl,  which use get()
without any check.

Is it a MessageContextImpl issue?  Or is there another way to return
multipart but with no any attachment response?

Thanks.
Xilai



Reply via email to