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

NIFI-8354 ExecuteStreamCommand processor doesn't delete the temp file… #4923

Merged
merged 2 commits into from Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -471,6 +471,13 @@ public void onTrigger(ProcessContext context, final ProcessSession session) thro
try {
process = builder.start();
} catch (IOException e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete() can throw several exceptions here, I think they should be handled.
maybe

public static boolean deleteFile(final File file, final Logger logger) {
, and the component logger passed so failures can be logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review, I have added the exception handling

I didn't use the FileUtils you mentioned
As far as I know, components need to use ComponentLog to record logs to distinguish the components in the same instance.
But FileUtils does not support it. so I handle the exception directly.

try {
if (!errorOut.delete()) {
logger.warn("Unable to delete file: " + errorOut.getAbsolutePath());
}
} catch (SecurityException se) {
logger.warn("Unable to delete file: '" + errorOut.getAbsolutePath() + "' due to " + se);
}
logger.error("Could not create external process to run command", e);
throw new ProcessException(e);
}
Expand Down