users@jersey.java.net

Re: [Jersey] need help with parsing multipart/form-data input ( NullPointerException in 1.0.1-SNAPSHOT )

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 07 Nov 2008 19:51:51 +0100

On Nov 7, 2008, at 7:34 PM, moiz_at_dohadwala.net wrote:

> Paul,
>
> Appreciate the prompt reply. The switch to the String type fixed the
> issue. Will you be uploading a new snapshot soon with your fix?

Yes, it is automatic, it takes about 30 to 60 mins after a commit
occurs.


> Also, would it also better report a type mis-match such as this?
>

You mean that the String "0.1" cannot be parsed as an int? If so you
then a NumberFormartException will be wrapped, which includes the
String value.

Paul.

> Thanks,
>
> -Moiz
>
> From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
> Sent: Friday, November 07, 2008 9:27 AM
> To: users_at_jersey.dev.java.net
> Subject: Re: [Jersey] need help with parsing multipart/form-data
> input ( NullPointerException in 1.0.1-SNAPSHOT )
>
>
> On Nov 7, 2008, at 6:01 PM, Paul Sandoz wrote:
>
> > Hi,
> >
> > Switching over to the users list as that is where all the action
> > happens.
> >
> > As a work around change the following:
> >
> > @FormParam( "protocol" ) int protocol
> >
> > to
> >
> > @FormParam( "protocol" ) String protocol
> >
> > The problem is that when the "multipart/form-data" media type is
> > used the registered message body readers are utilized and by default
> > there are none capable of reading bytes to Java primitive types.
> >
> >
> > I am working on a fix so that if a message body reader is not found
> > the following happens:
> >
> > 1) create an "extractor" following the rules of @*Param; and
> >
> > 2) if an extractor in 1) exists apply that to the UTF-8 decoded
> > String of the body part.
> >
>
> Fixed in the trunk.
>
> Paul.
>