Skip to content

NIFI-4988 Changed to handle an invalid ZIP file#2725

Closed
apsaltis wants to merge 2 commits intoapache:masterfrom
apsaltis:NIFI-4988
Closed

NIFI-4988 Changed to handle an invalid ZIP file#2725
apsaltis wants to merge 2 commits intoapache:masterfrom
apsaltis:NIFI-4988

Conversation

@apsaltis
Copy link
Contributor

Changed the exception handling so that an invalid ZIP file is handled. When an invalid zip is processed, the exception is an IllegalArgumentException which was not being handled and thus the session was being rollbacked.

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • [X ] Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • [X ] 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.

  • [X ] Has your PR been rebased against the latest commit within the target branch (typically master)?

  • [ X] Is your initial contribution a single, squashed commit?

For code changes:

  • [ X] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • [X ] Have you written or updated unit tests to verify your changes?
  • [N/A ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • [N/A ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • [N/A ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • [N/A ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • [N/A ] Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.

…ndled. When an invalid zip is processed, the exception is an IllegalArgumentException which was not being handled and thus the session was being rollbacked.
Copy link
Contributor

@bdesert bdesert left a comment

Choose a reason for hiding this comment

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

+1 LGTM.
I've reproduced the issue with provided invalid zip file. After applying the patch, issue has been resolved, flowfile being transferred to "failure" as expected.
Also, since InvalidPathException extends IllegaArgumentException, it's correct to replace it in catch with full backward compatibility on original type of exception.

@markap14
Copy link
Contributor

I think I'm missing something obvious... but the PR adds a new file, invalid_data.zip but it doesn't add it to the RAT exclusions in the pom.xml... yet, it still pass the contrib-check. I'm not sure why.

final List<MockFlowFile> unpacked = unpackRunner.getFlowFilesForRelationship(UnpackContent.REL_FAILURE);
for (final MockFlowFile flowFile : unpacked) {
final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key());
// final String folder = flowFile.getAttribute(CoreAttributes.PATH.key());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can probably remove this line.

@joewitt
Copy link
Contributor

joewitt commented May 21, 2018

@markap14 i think often RAT can detect something is a binary file and not subject to having a license header. It can't hurt to add the exclusion but i think it is normal that rat isn't unhappy about it.

@markap14
Copy link
Contributor

Ah, ok, I didn't realize that @joewitt - I thought it had to always be excluded. There are probably a handful of well-known magic headers or something then. Good to know!

@joewitt
Copy link
Contributor

joewitt commented May 21, 2018

also possible that I am totally full of it. One of these, possibly both, are true.

…usions and changing exception handling to just catch Exception, this will avoid the potential of other RuntimeException from escaping and causing this issue to re-emerge in the near future
@asfgit asfgit closed this in 6356d7b May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants