ChrisSamo632 commented on code in PR #6915:
URL: https://github.com/apache/nifi/pull/6915#discussion_r1093675510
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/servlets/ListenHTTPServlet.java:
##########
@@ -276,18 +274,17 @@ private Set<FlowFile>
handleMultipartRequest(HttpServletRequest request, Process
Set<FlowFile> flowFileSet = new HashSet<>();
String tempDir = System.getProperty("java.io.tmpdir");
request.setAttribute(Request.MULTIPART_CONFIG_ELEMENT, new
MultipartConfigElement(tempDir, multipartRequestMaxSize,
multipartRequestMaxSize, multipartReadBufferSize));
- Collection<Part> requestParts =
Collections.unmodifiableCollection(request.getParts());
- final Iterator<Part> parts = requestParts.iterator();
int i = 0;
- while (parts.hasNext()) {
- Part part = parts.next();
+ final Collection<Part> requestParts = request.getParts();
+ for (final Part part : requestParts) {
FlowFile flowFile = session.create();
try (OutputStream flowFileOutputStream = session.write(flowFile)) {
StreamUtils.copy(part.getInputStream(), flowFileOutputStream);
}
flowFile = saveRequestDetailsAsAttributes(request, session,
foundSubject, foundIssuer, flowFile);
flowFile = savePartDetailsAsAttributes(session, part, flowFile, i,
requestParts.size());
flowFileSet.add(flowFile);
+ part.delete();
Review Comment:
Would this be better in a `finally` block to ensure cleanup even if there
are exceptions thrown elsewhere in this loop/method after the possible point of
file creation?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]