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-11439 - correct provenance reporting parameter #7173

Closed
wants to merge 2 commits into from

Conversation

greyp9
Copy link
Contributor

@greyp9 greyp9 commented Apr 13, 2023

In previous PR, missed adjustment of URL supplied to provenance reporting subsystem.

Summary

NIFI-11439

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using mvn clean install -P contrib-check
    • JDK 11
    • JDK 17

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the Provenance Transit URI construction @greyp9. The strategy makes sense, just recommend an approach based on URI instead of URL construction.

Comment on lines 279 to 285
String transitUri;
try {
final URL url = new URL(storage.getOptions().getHost());
transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucketName, url.getHost(), key);
} catch (MalformedURLException e) {
transitUri = e.getClass().getSimpleName();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Using URI.create() avoids the checked MalformedURLException and because the Storage API URL must be valid for making the request, recommend the following approach:

Suggested change
String transitUri;
try {
final URL url = new URL(storage.getOptions().getHost());
transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucketName, url.getHost(), key);
} catch (MalformedURLException e) {
transitUri = e.getClass().getSimpleName();
}
final URI storageApiUri = URI.create(storage.getOptions().getHost());
final String transitUri = String.format("%s://%s.%s/%s", uri,getScheme(), bucketName, uri.getHost(), key);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's better.

Comment on lines 548 to 554
String transitUri;
try {
final URL url = new URL(storage.getOptions().getHost());
transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucket, url.getHost(), key);
} catch (MalformedURLException e) {
transitUri = e.getClass().getSimpleName();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the implementation could be moved to a protected getTransitUri() method in AbstractGCSProcessor, or the changed could be implemented in both classes.

Suggested change
String transitUri;
try {
final URL url = new URL(storage.getOptions().getHost());
transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucket, url.getHost(), key);
} catch (MalformedURLException e) {
transitUri = e.getClass().getSimpleName();
}
final URI storageApiUri = URI.create(storage.getOptions().getHost());
final String transitUri = String.format("%s://%s.%s/%s", uri,getScheme(), bucketName, uri.getHost(), key);

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for making the adjustments and addressing the feedback @greyp9, the latest version looks good! +1 merging

exceptionfactory pushed a commit that referenced this pull request Apr 14, 2023
This closes #7173

Signed-off-by: David Handermann <exceptionfactory@apache.org>
(cherry picked from commit cff7808)
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.

2 participants