Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4383 - avoid NPE from MultiPart Cleanup #4388

Closed
wants to merge 9 commits into from
Expand Up @@ -59,11 +59,10 @@
public class MultiPartFormInputStream
{
private static final Logger LOG = Log.getLogger(MultiPartFormInputStream.class);
private static final MultiMap<Part> EMPTY_MAP = new MultiMap<>(Collections.emptyMap());
private InputStream _in;
private MultipartConfigElement _config;
private String _contentType;
private MultiMap<Part> _parts;
private MultiMap<Part> _parts = new MultiMap<>();
private Throwable _err;
private File _tmpDir;
private File _contextTmpDir;
Expand Down Expand Up @@ -345,7 +344,6 @@ public MultiPartFormInputStream(InputStream in, String contentType, MultipartCon
{
if (((ServletInputStream)in).isFinished())
{
_parts = EMPTY_MAP;
_parsed = true;
return;
}
Expand All @@ -358,7 +356,7 @@ public MultiPartFormInputStream(InputStream in, String contentType, MultipartCon
*/
public boolean isEmpty()
{
if (_parts == null)
if (_parts.isEmpty())
return true;

Collection<List<Part>> values = _parts.values();
Expand All @@ -379,7 +377,7 @@ public boolean isEmpty()
@Deprecated
public Collection<Part> getParsedParts()
{
if (_parts == null)
if (_parts.isEmpty())
lachlan-roberts marked this conversation as resolved.
Show resolved Hide resolved
return Collections.emptyList();

Collection<List<Part>> values = _parts.values();
Expand Down Expand Up @@ -492,9 +490,6 @@ protected void parse()
Handler handler = new Handler();
lachlan-roberts marked this conversation as resolved.
Show resolved Hide resolved
try
{
// initialize
_parts = new MultiMap<>();

// if its not a multipart request, don't parse it
if (_contentType == null || !_contentType.startsWith("multipart/form-data"))
return;
Expand Down