You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Eric Chatellier (Jira)" <ji...@apache.org> on 2022/12/14 16:39:00 UTC

[jira] [Comment Edited] (CXF-8669) Multipart annotation not working 3.4.6 onwards.

    [ https://issues.apache.org/jira/browse/CXF-8669?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17647599#comment-17647599 ] 

Eric Chatellier edited comment on CXF-8669 at 12/14/22 4:38 PM:
----------------------------------------------------------------

Hi,

I investigated a lot this bug.

In version {+}3.4.3{+}, for *Long* parameter, {*}org.apache.cxf.jaxrs.ext.multipart.{_}*Attachment#getContentType(){_}{*}* returns _MediaType.TEXT_PLAIN_TYPE_ because
{*}org.apache.cxf.attachment.AttachmentDataSource.{*}{*}getContentType(){*} also return "null".
So "{_}text/plain"{_} parameters are handled by *PrimitiveTextProvider* and then converted to {*}long{*}.

 

In version {+}3.5.5{+}, there is a change in {*}org.apache.cxf.attachment.AttachmentDataSource.{*}{*}getContentType(){*} returning a default {_}"{_}{_}application/octet-stream"{_} content type (maybe due too [this commit|[https://github.com/apache/cxf/commit/d27ad0157e49fdd601f702823155ff813880de5b]]
There is no *MessageBodyReader* implementation to hander {_}application/octet-stream{_}, so parameter is not converted and this result to "{_}null{_}" value.
 
Hope this helps


was (Author: JIRAUSER288052):
Hi,

I investigated a lot this bug.

In version {+}3.4.3{+}, for *Long* parameter, *org.apache.cxf.jaxrs.ext.multipart.{_}*Attachment#getContentType()*{_}* returns _MediaType.TEXT_PLAIN_TYPE_ because
{*}org.apache.cxf.attachment.AttachmentDataSource.{*}{*}getContentType(){*} also return "null".
So "{_}text/plain"{_} parameters are handled by *PrimitiveTextProvider* and then converted to {*}long{*}.
 
In version {+}3.5.5{+}, there is a change in {*}org.apache.cxf.attachment.AttachmentDataSource.{*}{*}getContentType(){*} returning a default {_}"{_}{_}application/octet-stream"{_} content type (maybe due too [this commit|[https://github.com/apache/cxf/commit/d27ad0157e49fdd601f702823155ff813880de5b].]
There is no *MessageBodyReader* implementation to hander {_}application/octet-stream{_}, so parameter is not converted and this result to "{_}null{_}" value.
 
Hope this helps

> Multipart annotation not working 3.4.6 onwards.
> -----------------------------------------------
>
>                 Key: CXF-8669
>                 URL: https://issues.apache.org/jira/browse/CXF-8669
>             Project: CXF
>          Issue Type: Bug
>            Reporter: Abhishek Rana
>            Priority: Major
>
> Hello Team,
> I have following API declaration
> {code:java}
> @POST
>     @Path("/{configurationName}.diff")
>     @Consumes(MediaType.MULTIPART_FORM_DATA)
>     @Produces({MediaType.APPLICATION_JSON})
>     ConfigurationDiffDTO diff(@PathParam("configurationName") String configurationName,
>         @Multipart(value = "fromRev", required = false) Long fromRev, @Multipart(value = "toRev", required = false) Long toRev, @Multipart(value = "file", required = false) Attachment file);
> {code}
> Above declaration works fine till 3.4.5 , after I upgraded to 3.5.0 (even 3.4.6) , multipart form values (fromRev and toRev) they are coming as null. 
> Is it a regression?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)