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

DROOLS-7552: improve updateObjectTypesList() #5552

Merged
merged 2 commits into from
Oct 13, 2023
Merged

Conversation

nprentza
Copy link
Contributor

DROOLS-7552

This improvement is related to benchmark FireAndAlarmBenchmark findings (DROOLS-7545).

// if count==0 then remove entry
if (uniqueObjectTypesInStore.get(object.getClass().getName()) == 0) {
uniqueObjectTypesInStore.remove(object.getClass().getName());
if (inverseStorage.keySet().stream().filter(sObject -> sObject.getClass().equals(object.getClass())).findAny()!=null){
Copy link
Contributor

@tkobayas tkobayas Oct 12, 2023

Choose a reason for hiding this comment

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

findAny() returns Optional.empty() when there is no match, so comparing with null is not right, I think. Please check the execution path when the object class doesn't exist in inverseStorage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tkobayas your comment is correct, comparing with null is not right, it always returns true. So, I will replace line 125 with
if (!inverseStorage.keySet().stream().filter(sObject -> sObject.getClass().equals(object.getClass())).findAny().isEmpty())

Copy link
Contributor

@tkobayas tkobayas 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!

@mariofusco mariofusco merged commit d62dde5 into apache:main Oct 13, 2023
rgdoliveira pushed a commit to kiegroup/drools that referenced this pull request Dec 13, 2023
* updateObjectTypesList() improvements

* use isEmpty with findAny
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