Currently if I have a custom bean (MyBean) and I use it with MediaType.MULTIPART_FORM_DATA content type and MultipartForm annotation in a rest service (MyService.createMyBean()) if some property is null an NPE is thrown. I think with a small modification in resteasy.plugins.providers.multipart.AbstractMultipartFormDataWriter these null properties could be simply skipped. As in multipart/form-data every part has a name it's not a problem if some parts are not present.
Suggested modification in resteasy.plugins.providers.multipart.AbstractMultipartFormDataWriter:
protected void writeParts(MultipartOutput multipartOutput, OutputStream entityStream, byte[] boundaryBytes) throws IOException
{
MultipartFormDataOutput form = (MultipartFormDataOutput) multipartOutput;
for (Map.Entry<String, OutputPart> entry : form.getFormData().entrySet())
}
MyBean.java:
public class MyBean
{
@FormParam("someBinary")
@PartType(MediaType.APPLICATION_OCTET_STREAM)
private InputStream someBinary;
public InputStream getSomeBinary()
{ return someBinary; }public void setSomeBinary(InputStream someBinary)
{ this.someBinary = someBinary; }}
MyService.java:
@Path("/mime")
public class MyService
{
@GET
@Produces(MediaType.MULTIPART_FORM_DATA)
@MultipartForm
public MyBean createMyBean()
}