Improved: Improve ObjectInputStream class
(OFBIZ-10837) While working on OFBIZ-11633 I crossed an issue in R18 (not in trunk) where objects from org.apache.commons.fileupload (namely DiskFileItem and FileItemHeadersImpl) are not serializable. While at it I decided to handle at the SafeObjectInputStream level the "fileItems" case I already crossed with, OFBIZ-11534, in RequestHandler It has an inconvenient in R18 (not in trunk) where ObjectInputStream can't handle a null class (of course) and so return a benign exception in log (only). I believe it's better to handle these specific cases at the lower possible level in all supported branches.
This commit is contained in:
@@ -64,6 +64,10 @@ public final class SafeObjectInputStream extends ObjectInputStream {
|
||||
@Override
|
||||
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
|
||||
if (!whitelistPattern.matcher(classDesc.getName()).find()) {
|
||||
// DiskFileItem, FileItemHeadersImpl are not serializable.
|
||||
if (classDesc.getName().contains("org.apache.commons.fileupload")) {
|
||||
return null;
|
||||
}
|
||||
Debug.logWarning("***Incompatible class***: "
|
||||
+ classDesc.getName()
|
||||
+ ". Please see OFBIZ-10837. Report to dev ML if you use OFBiz without changes. "
|
||||
|
||||
@@ -93,6 +93,10 @@ public final class UtilObject {
|
||||
Object obj = null;
|
||||
try {
|
||||
obj = getObjectException(bytes);
|
||||
// DiskFileItem, FileItemHeadersImpl are not serializable. So SafeObjectInputStream::resolveClass return null
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
} catch (ClassNotFoundException | IOException e) {
|
||||
Debug.logError(e, module);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user