Fixed: Error in uploading very large files, ie >2MB

(OFBIZ-11534)

This was not supposed to be committed, actually (wrong) part of OFBIZ-11597

Fixed: Error in uploading very large files, ie >2MB

(OFBIZ-11534)

There is an issue in uploading large files, I am able to upload files up to 2 GB
successfully but getting an error when trying to upload a file larger than 2GB.

Example -
1. Go to party profile -
https://demo-trunk.ofbiz.apache.org/partymgr/control/viewprofile?partyId=admin
2. Try to create a party content with a file larger than 2 GB
3. Error on console

jleroux:
For a 2GB+ file you need to set Xmx to more than the double of the file size,
eg: gradlew ofbiz -PjvmArgs="-Xms1024M -Xmx5048M"

You then get another small issue (only in log) when redirecting to send the
partyId parameter.

This is because, DiskFileItem is a temporary Object with a null value contained
in "fileItems" attribute. It can't be detected by UtilMisc::makeMapSerializable
and that makes "fileItems" not serializable. So it must be removed from
reqAttrMap.

Thanks: Chandan Khandelwal for report, Michael for suggesting a very large file
to upload
This commit is contained in:
Jacques Le Roux
2020-04-16 16:16:14 +02:00
parent 9530d4b441
commit 9f5ebc48fd
@@ -835,6 +835,10 @@ public class RequestHandler {
}
}
if (reqAttrMap.size() > 0) {
// fileItems is not serializable.
// It contains a temporary DiskFileItem with a null value than can't be detected by UtilMisc::makeMapSerializable
// So it must be removed from reqAttrMap. See OFBIZ-11534
reqAttrMap.remove("fileItems");
byte[] reqAttrMapBytes = UtilObject.getBytes(reqAttrMap);
if (reqAttrMapBytes != null) {
req.getSession().setAttribute("_REQ_ATTR_MAP_", StringUtil.toHexString(reqAttrMapBytes));