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

Fixed check Optional not null #11015

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

ppatierno
Copy link
Member

While reviewing a TO related PR I came across the following code which I think is "wrong":

if (configChanges != null && configChanges.isEmpty()) {
                LOGGER.debugCr(reconcilableTopic.reconciliation(), "Config changes {}", configChanges);
            } else {
                LOGGER.debugCr(reconcilableTopic.reconciliation(), "No config change");
            }

I see a couple of issues here:

  • the configChanges != null is not needed because it's always true. The configChanges is an Optional coming from a findFirst() on a stream which always returns an Optional which can be empty or not but never a null.
  • the logging seems to be in the opposite order. If empty logs the config changes, if not empty logs "no config change".

Signed-off-by: Paolo Patierno <[email protected]>
@ppatierno ppatierno added this to the 0.46.0 milestone Jan 7, 2025
@ppatierno ppatierno requested review from fvaleri and a team January 7, 2025 15:05
@ppatierno
Copy link
Member Author

@fvaleri as TO expert, what do you think about this? If that's ok with you I will run regression tests.

Copy link
Contributor

@fvaleri fvaleri left a comment

Choose a reason for hiding this comment

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

You just forgot to call get, otherwise LGTM.
Thanks for catching this.

Signed-off-by: Paolo Patierno <[email protected]>
@ppatierno
Copy link
Member Author

/azp run regression

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@fvaleri fvaleri left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@ppatierno ppatierno merged commit 5efc0d4 into strimzi:main Jan 8, 2025
21 checks passed
@ppatierno ppatierno deleted the fix-check-optional-not-empty branch January 8, 2025 08:16
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.

3 participants