This is an automated email from the ASF dual-hosted git repository.
turcsanyi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/master by this push:
new c396927 NIFI-7594 In HandleHttpRequest deleting multipart file
resources after processing.
c396927 is described below
commit c396927299586b896df4ebc745793b4c451f3898
Author: Tamas Palfy <[email protected]>
AuthorDate: Wed Jul 1 16:54:46 2020 +0200
NIFI-7594 In HandleHttpRequest deleting multipart file resources after
processing.
This closes #4379.
Signed-off-by: Peter Turcsanyi <[email protected]>
---
.../apache/nifi/processors/standard/HandleHttpRequest.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
index bdc9a99..86ee126 100644
---
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
+++
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpRequest.java
@@ -640,8 +640,9 @@ public class HandleHttpRequest extends AbstractProcessor {
final int readBufferSize =
context.getProperty(MULTIPART_READ_BUFFER_SIZE).asDataSize(DataUnit.B).intValue();
String tempDir = System.getProperty("java.io.tmpdir");
request.setAttribute(Request.MULTIPART_CONFIG_ELEMENT, new
MultipartConfigElement(tempDir, requestMaxSize, requestMaxSize,
readBufferSize));
+ List<Part> parts = null;
try {
- List<Part> parts = ImmutableList.copyOf(request.getParts());
+ parts = ImmutableList.copyOf(request.getParts());
int allPartsCount = parts.size();
final String contextIdentifier = UUID.randomUUID().toString();
for (int i = 0; i < allPartsCount; i++) {
@@ -666,6 +667,16 @@ public class HandleHttpRequest extends AbstractProcessor {
} catch (IOException | ServletException | IllegalStateException e) {
handleFlowContentStreamingError(session, container, request,
Optional.absent(), e);
return;
+ } finally {
+ if (parts != null) {
+ for (Part part : parts) {
+ try {
+ part.delete();
+ } catch (Exception e) {
+ getLogger().error("Couldn't delete underlying storage for
{}", new Object[]{part}, e);
+ }
+ }
+ }
}
} else {
FlowFile flowFile = session.create();