This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release18.12
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
The following commit(s) were added to refs/heads/release18.12 by this push:
new af464df Fixed: NotSerializableException using uploadPartyContentFile
service (OFBIZ-12050)
af464df is described below
commit af464dfa7071bef39d686a4d3109b2672844dbfb
Author: Jacques Le Roux <[email protected]>
AuthorDate: Fri Nov 6 10:59:58 2020 +0100
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
---
.../main/java/org/apache/ofbiz/base/util/UtilMisc.java | 16 +++++++++++++++-
.../org/apache/ofbiz/webapp/control/RequestHandler.java | 7 +++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git
a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
index b6985a6..9176094 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilMisc.java
@@ -197,13 +197,27 @@ 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.
* @param sortKeys List of Map keys to sort by.
diff --git
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
index 1c18dd2..fc246d2 100644
---
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
+++
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
@@ -25,6 +25,7 @@ import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.X509Certificate;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@@ -901,6 +902,12 @@ public class RequestHandler {
// See OFBIZ-750 and OFBIZ-11123 for cases where a value
in an inner Map is not serializable
UtilMisc.makeMapSerializable(UtilGenerics.cast(obj));
}
+ if (obj instanceof ArrayList) {
+ // See OFBIZ-10250 for cases where a value in an ArrayList
is not serializable
+ @SuppressWarnings("unchecked")
+ ArrayList<Object> arrayList = (ArrayList<Object>) obj;
+ UtilMisc.makeArrayListSerializable(arrayList);
+ }
reqAttrMap.put(name, obj);
}
}