cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From XiLai Dai <xl...@talend.com>
Subject RE: No any Attachment will throw IndexOutOfBoundsException in org.apache.cxf.jaxrs.ext.MessageContextImpl
Date Tue, 04 Sep 2012 02:26:38 GMT
Thanks Sergey!

That means in case atts > 0 , then,  return Response.ok(new MultipartBody(atts, true)).build();
                       Else,   return Response.ok().build();

And nothing to be changed in the wadl ?   just keep this <response> ?
                    <response status="200">
                        <representation mediaType="multipart/mixed;type=application/xml"
/>
                    </response>

Thanks, Xilai
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com] 
Sent: Monday, September 03, 2012 9:16 PM
To: users@cxf.apache.org; XiLai Dai
Subject: Re: No any Attachment will throw IndexOutOfBoundsException in org.apache.cxf.jaxrs.ext.MessageContextImpl

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* <xldai@talend.com <mailto:xldai@talend.com>>
> Date: Wed, Aug 29, 2012 at 10:17 AM
> Subject: No any Attachment will throw IndexOutOfBoundsException in
> org.apache.cxf.jaxrs.ext.MessageContextImpl
> To: "users@cxf.apache.org <mailto:users@cxf.apache.org>"
> <users@cxf.apache.org <mailto:users@cxf.apache.org>>
>
>
> 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
>



Mime
View raw message