Skip to content

Commit

Permalink
Issue 4383 - changes from review
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
  • Loading branch information
lachlan-roberts committed Jan 23, 2020
1 parent 059bbfa commit c4a3855
Showing 1 changed file with 9 additions and 10 deletions.
Expand Up @@ -60,11 +60,10 @@
* is done by the parsing thread.
* </p>
* <pre>{@code
*
* UNPARSED - Parsing has not started, there are no parts which need to be cleaned up.
* PARSING - The parsing thread is reading from the InputStream and generating parts.
* PARSED - Parsing has complete and no more parts will be generated.
* ERROR - deleteParts() has been called while we were in parsing state.
* DELETING - deleteParts() has been called while we were in PARSING state, parsing thread will do the delete.
* DELETED - The parts have been deleted, this is the terminal state.
*
* deleteParts()
Expand All @@ -86,8 +85,8 @@ private enum State
UNPARSED,
PARSING,
PARSED,
DELETED,
ERROR
DELETING,
DELETED
}

private static final Logger LOG = Log.getLogger(MultiPartFormInputStream.class);
Expand Down Expand Up @@ -413,11 +412,11 @@ public void deleteParts()
switch (state)
{
case DELETED:
case ERROR:
case DELETING:
return;

case PARSING:
state = State.ERROR;
state = State.DELETING;
return;

case UNPARSED:
Expand All @@ -430,10 +429,10 @@ public void deleteParts()
}
}

uncheckedDeleteParts();
delete();
}

private void uncheckedDeleteParts()
private void delete()
{
MultiException err = null;
for (List<Part> parts : _parts.values())
Expand Down Expand Up @@ -638,7 +637,7 @@ else if (len == -1)
state = State.PARSED;
break;

case ERROR:
case DELETING:
state = State.DELETED;
cleanup = true;
break;
Expand All @@ -649,7 +648,7 @@ else if (len == -1)
}

if (cleanup)
uncheckedDeleteParts();
delete();
}
}

Expand Down

0 comments on commit c4a3855

Please sign in to comment.