Fixed: NotSerializableException using uploadPartyContentFile service (OFBIZ-12050)

This error appears after trying to upload a file to party content:

2020-11-06 07:48:22,488 |jsse-nio-8443-exec-7 |RequestHandler                |I|
Sending redirect to:
[https://localhost:8443/partymgr/control/viewprofile?partyId=admin].
2020-11-06 07:48:29,288 |jsse-nio-8443-exec-7 |UtilObject                    |E|
null
java.io.NotSerializableException: org.apache.commons.fileupload.disk.DiskFileItem

# Conflicts handled by hand
#	framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
#	framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
This commit is contained in:
Jacques Le Roux
2020-11-06 11:07:19 +01:00
parent 9cfd5a73e1
commit af464dfa70
2 changed files with 22 additions and 1 deletions
@@ -197,12 +197,26 @@ public final class UtilMisc {
if (Debug.verboseOn()) {
Debug.logVerbose("Found Map value that is not Serializable: " + mapEntry.getKey() + "=" + mapEntry.getValue(), module);
}
}
}
for (String keyToRemove: keysToRemove) { map.remove(keyToRemove); }
}
/**
* This change an ArrayList to be Serializable by removing all entries that are not Serializable.
* @param arrayList
*/
public static <V> void makeArrayListSerializable(ArrayList<Object> arrayList) {
// now filter out all non-serializable values
Iterator itr = arrayList.iterator();
while (itr.hasNext()) {
Object obj = itr.next();
if (!(obj instanceof Serializable)) {
itr.remove();
}
}
}
/**
* Sort a List of Maps by specified consistent keys.
* @param listOfMaps List of Map objects to sort.