users@jersey.java.net

[Jersey] Re: File upload is broken in Jersey 2.17

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Wed, 13 May 2015 11:01:44 +0200

Hi Scott,

Can you please open a new bug in our Jira?

Thank you,
Marek

> On 12 May 2015, at 18:32, Scott Palmer <swpalmer_at_gmail.com> wrote:
>
> This is the commit that did it:
>
> https://github.com/jersey/jersey/commit/d90369ca0e872df280979f04669894871f5c8189#diff-71e5b60df38390f13c313b6cc9847efd <https://github.com/jersey/jersey/commit/d90369ca0e872df280979f04669894871f5c8189#diff-71e5b60df38390f13c313b6cc9847efd>
>
> The problem is that the temp file can't be renamed because an empty file with the destination name is created and left there, blocking the moveTo from succeeding.
>
> https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/internal/FormDataParamValueFactoryProvider.java#L253 <https://github.com/jersey/jersey/blob/master/media/multipart/src/main/java/org/glassfish/jersey/media/multipart/internal/FormDataParamValueFactoryProvider.java#L253>
>
>
> The problem is hidden because the ultimate renameTo call in WeakDataFile simply logs the failure without letting the caller know that the rename failed.
>
> May 12, 2015 11:40:50 AM org.jvnet.mimepull.WeakDataFile renameTo
> INFO: File C:\Users\SCOTT~1.PAL\AppData\Local\Temp\MIME9174014175637264696.tmp was not moved to C:\Users\SCOTT~1.PAL\AppData\Local\Temp\rep818068880122345050tmp
>
> The result is that the web service, with a parameter declared as: @FormDataParam("file") File file, is always given a reference to an empty temp file.
>
> Regards,
>
> Scott
>