-
Notifications
You must be signed in to change notification settings - Fork 2
fix(examples): improve logging and setup logic in examples #316
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
Conversation
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
Summary of ChangesHello @cshamrick, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Java SDK examples by integrating Log4j2 for improved logging and debugging capabilities. It also introduces more robust and dynamic setup logic in several examples, particularly for creating attributes and subject mappings, ensuring that dependent resources are either fetched or created on the fly. These changes aim to make the examples more self-contained, easier to understand, and more resilient to changes in the environment. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request successfully improves the examples by introducing Log4j2 for better logging and enhancing the setup logic to be more robust, particularly in CreateSubjectMapping.java. However, there are a few areas for improvement. A significant issue is that the SDK resource, which is AutoCloseable, is not being closed in most of the example files, potentially leading to resource leaks. I've recommended using try-with-resources statements to address this. Additionally, there are several instances where collections are accessed without checking if they are empty, which could cause IndexOutOfBoundsException. Lastly, CreateNamespace.java was missed during the logging refactor and still uses System.out.println.
examples/src/main/java/io/opentdf/platform/CreateAttribute.java
Outdated
Show resolved
Hide resolved
examples/src/main/java/io/opentdf/platform/CreateNamespace.java
Outdated
Show resolved
Hide resolved
examples/src/main/java/io/opentdf/platform/CreateSubjectConditionSet.java
Outdated
Show resolved
Hide resolved
examples/src/main/java/io/opentdf/platform/ListSubjectMappings.java
Outdated
Show resolved
Hide resolved
examples/src/main/java/io/opentdf/platform/CreateNamespace.java
Outdated
Show resolved
Hide resolved
examples/src/main/java/io/opentdf/platform/GetEntitlements.java
Outdated
Show resolved
Hide resolved
X-Test Results✅ go-v0.4.34 |
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
X-Test Results✅ go-v0.4.34 |
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
X-Test Results✅ js-v0.4.34 |
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
elizabethhealy
left a comment
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.
lgtm! it doesnt look like we run these as part of ci, maybe we can add a ticket to the backlog, hopefully that would help in keeping these up to date
examples/src/main/java/io/opentdf/platform/CreateAttribute.java
Outdated
Show resolved
Hide resolved
X-Test Results✅ go-v0.4.34 |
Signed-off-by: Scott Hamrick <2623452+cshamrick@users.noreply.github.com>
|
X-Test Results✅ js-v0.4.34 |
X-Test Failure Report |
X-Test Results✅ go-v0.4.34 |



Key Changes:
examplesscope for conventional commits.These improvements enhance the quality and usability of the examples, providing a better experience for developers using the Java SDK.