mirror of
https://github.com/apache/struts.git
synced 2026-08-31 11:24:28 +00:00
Fixes issue with NPE
This commit is contained in:
@@ -36,18 +36,22 @@ public class UploadedFileConverter extends DefaultTypeConverter {
|
||||
@Override
|
||||
public Object convertValue(Map<String, Object> context, Object target, Member member, String propertyName, Object value, Class toType) {
|
||||
if (File.class.equals(toType)) {
|
||||
LOG.warn("Converting {} into {}, consider switching to {} and do not access {} directly!",
|
||||
LOG.debug("Converting {} into {}, consider switching to {} and do not access {} directly!",
|
||||
File.class.getName(), UploadedFile.class.getName(), UploadedFile.class.getName(), File.class.getName());
|
||||
|
||||
Object obj;
|
||||
if (value.getClass().isArray() && Array.getLength(value) == 1) {
|
||||
Object obj = Array.get(value, 0);
|
||||
if (obj instanceof UploadedFile) {
|
||||
UploadedFile file = (UploadedFile) obj;
|
||||
if (file.getContent() instanceof File) {
|
||||
return file.getContent();
|
||||
}
|
||||
return new File(file.getAbsolutePath());
|
||||
obj = Array.get(value, 0);
|
||||
} else {
|
||||
obj = value;
|
||||
}
|
||||
|
||||
if (obj instanceof UploadedFile) {
|
||||
UploadedFile file = (UploadedFile) obj;
|
||||
if (file.getContent() instanceof File) {
|
||||
return file.getContent();
|
||||
}
|
||||
return new File(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user