users@jersey.java.net

[Jersey] File upload is broken in Jersey 2.17

From: Scott Palmer <swpalmer_at_gmail.com>
Date: Tue, 12 May 2015 12:32:21 -0400

This is the commit that did it:

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


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