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-8200: Modifying PutAzureDataLakeStorage to delete temp file if e… #4815
Conversation
…xception was thrown in uploadContent()
e0c8e49
to
81c2dec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix! I tested it with interrupting internet access while uploading a large file. I found one case that I think needs to be handled, please check my comment with a proposed solution.
@@ -126,6 +126,9 @@ public void onTrigger(final ProcessContext context, final ProcessSession session | |||
if (length > 0) { | |||
try (final InputStream rawIn = session.read(flowFile); final BufferedInputStream bufferedIn = new BufferedInputStream(rawIn)) { | |||
uploadContent(fileClient, bufferedIn, length); | |||
} catch (Exception e) { | |||
fileClient.delete(); | |||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception e is suppressed if fileClient.delete() also throws an exception. My recommendation is to put a try-catch-finally around delete(). In the catch only an error message needs to be logged, and in the finally the original exception 'e' can be thrown forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your help, corrected in the next commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
LGTM
@timeabarna What happens when an existing file is being overwritten with the Conflict Resolution Strategy set to replace? |
@jfrazee Thanks for pointing this out. I've checked the original version and the behaviour is the following:
With this current modification the behaviour:
I'm exploring the possibility using temp files instead of inline replacement however I think this should be covered by another Jira ticket. |
@timeabarna That's what I figured. It's not ideal, but this isn't a regression. Can we clarify the delete behavior in the docs? |
@timeabarna Oh, also, yes it makes sense to have another JIRA for some more sophisticated handling, which should probably be done. Ideally we should try to have the same behavior we can get with HDFS, which I think is achievable since renames are atomic. |
@jfrazee Sure thing, will update the docs accordingly |
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
</ul> | ||
|
||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a trailing newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All suggestions have been applied. Thanks Joey for your help.
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
...docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html
Outdated
Show resolved
Hide resolved
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
…ain/resources/docs/org.apache.nifi.processors.azure.storage.PutAzureDataLakeStorage/additionalDetails.html Co-authored-by: Joey <joey.frazee@icloud.com>
Thanks for this @timeabarna +1 |
…eption was thrown in uploadContent() This closes #4815 Signed-off-by: Joey Frazee <jfrazee@apache.org>
…eption was thrown in uploadContent() This closes apache#4815 Signed-off-by: Joey Frazee <jfrazee@apache.org>
…eption was thrown in uploadContent() This closes apache#4815 Signed-off-by: Joey Frazee <jfrazee@apache.org>
…xception was thrown in uploadContent()
https://issues.apache.org/jira/browse/NIFI-8200
Description of PR
delete temp file if exception was thrown in uploadContent()
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically
main
)?Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not
squash
or use--force
when pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean install
at the rootnifi
folder?LICENSE
file, including the mainLICENSE
file undernifi-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-assembly
?.displayName
in addition to .name (programmatic access) for each of the new properties?For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.