So the JVM implementation is buggy (not the Netty one), since the transferTo method on FileChannel should be optimized carefully in JVM, taking in consideration the memory footprint. If I'm correct, this method is system optimized, so the reason we used it.
And for the record, the "renameTo" method of Netty first tries to use the simplest "renameTo" method on File directly, since it is the most efficient one, then if not possible (such as different FileSystem under the wood), then it must copy and delete manually.

So we need to make the second part fully manually and not using the FileChannel optimization... This is a sad news, as it will be less efficient than the native one.
Am I correct ?

Now the issue is the optimal chunk size. For nowadays, 8KB could be considered as a good tradeoff among all filesystems implementation...
 I meant we can call transferTo() multiple times with smaller length parameter, rather than completely falling back to old I/O.
 I update the proposal accordingly. Thank @trustin and @normanmaurer 
 Should correct the issue...
Should we ask the user to check first before to close this issue?
 Just close it and tell him that it will be part of 3.5.1.Final ;)

2012/6/15 Frédéric Brégier
reply@reply.github.com:

> Should correct the issue...
> Should we ask the user to check first before to close this issue?
> 
> ---
> 
> Reply to this email directly or view it on GitHub:
> https://github.com/netty/netty/issues/398#issuecomment-6353273

AbstractDiskHttpData.renameTo() can fail when mmap'ing fails.
See: http://stackoverflow.com/questions/11006968/netty-file-upload-out-of-memory-error

The current implementation of `renameTo` is not correct.  It has to copy data chunk by chunk (e.g. 8KiB) instead of issuing full transfer at once.

src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
index 010bd1d55ff..e1400cae675 100644
--- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
+++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/AbstractDiskHttpData.java
@@ -292,8 +292,8 @@ public boolean renameTo(File dest) throws IOException {
             int chunkSize = 8196;
             long position = 0;
             while (position < size) {
-                if (chunksize < size - position) {
-                    chunksize = size - position;
+                if (chunkSize < size - position) {
+                    chunkSize = (int) (size - position);
                 }
                 position += in.transferTo(position, chunkSize , out);
             }
