StreamUtils.emptyInput() for consistent empty InputStream exposure
Issue: SPR-13563
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.http.converter.json;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
@@ -54,6 +53,7 @@ import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -761,7 +761,7 @@ public class Jackson2ObjectMapperBuilder {
|
||||
private static final XMLResolver NO_OP_XML_RESOLVER = new XMLResolver() {
|
||||
@Override
|
||||
public Object resolveEntity(String publicID, String systemID, String base, String ns) {
|
||||
return new ByteArrayInputStream(new byte[0]);
|
||||
return StreamUtils.emptyInput();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.http.converter.xml;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
@@ -46,6 +45,7 @@ import org.springframework.http.converter.GenericHttpMessageConverter;
|
||||
import org.springframework.http.converter.HttpMessageConversionException;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.HttpMessageNotWritableException;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
* An {@code HttpMessageConverter} that can read XML collections using JAXB2.
|
||||
@@ -256,7 +256,7 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
|
||||
private static final XMLResolver NO_OP_XML_RESOLVER = new XMLResolver() {
|
||||
@Override
|
||||
public Object resolveEntity(String publicID, String systemID, String base, String ns) {
|
||||
return new ByteArrayInputStream(new byte[0]);
|
||||
return StreamUtils.emptyInput();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMe
|
||||
private static final XMLResolver NO_OP_XML_RESOLVER = new XMLResolver() {
|
||||
@Override
|
||||
public Object resolveEntity(String publicID, String systemID, String base, String ns) {
|
||||
return new ByteArrayInputStream(new byte[0]);
|
||||
return StreamUtils.emptyInput();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.web.multipart.commons;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -28,10 +27,11 @@ import org.apache.commons.fileupload.disk.DiskFileItem;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* MultipartFile implementation for Apache Commons FileUpload.
|
||||
* {@link MultipartFile} implementation for Apache Commons FileUpload.
|
||||
*
|
||||
* @author Trevor D. Cook
|
||||
* @author Juergen Hoeller
|
||||
@@ -124,7 +124,7 @@ public class CommonsMultipartFile implements MultipartFile, Serializable {
|
||||
throw new IllegalStateException("File has been moved - cannot be read again");
|
||||
}
|
||||
InputStream inputStream = this.fileItem.getInputStream();
|
||||
return (inputStream != null ? inputStream : new ByteArrayInputStream(new byte[0]));
|
||||
return (inputStream != null ? inputStream : StreamUtils.emptyInput());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user