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

Fix change detection for textual things #4076

Merged
merged 4 commits into from
May 2, 2024
Merged

Conversation

jimtng
Copy link
Contributor

@jimtng jimtng commented Feb 1, 2024

Fixes #3235

General Problem Description:
When a .things file contains multiple Things and only one thing was changed, update notifications will be sent for all the things inside the file.

It should only send an update notification for the one thing that changed, and not the other things.

This is caused by two issues:

  • The old things weren't removed (causing memory leak?), resulting in accumulation of multiple versions and comparing the new one against the old one resulting in erroneous update
  • Numeric values (usually entered as integer) in a newly loaded Channel Configuration properties (in the newThing) are stored as BigDecimal with Scale 0, but subsequent normalization changed it to scale 1 (in the oldThing). This makes the equals(oldThing, newThing) to always return false even when nothing has changed, which leads to calling notifyListenersAboutUpdatedElement erroneously.

@jimtng jimtng requested a review from a team as a code owner February 1, 2024 09:55
@jimtng jimtng force-pushed the things-reload-fix branch 2 times, most recently from 9d99686 to 8a6ed12 Compare February 1, 2024 11:47
@lolodomo
Copy link
Contributor

lolodomo commented May 1, 2024

@jimtng : conflicts is mentioned

It would be cool to have a review of your PR. I tale a look but I am not enough aware of the code you updated to confirm that your changes are valid.

Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

LGTM

@J-N-K J-N-K added the bug An unexpected problem or unintended behavior of the Core label May 1, 2024
@J-N-K
Copy link
Member

J-N-K commented May 1, 2024

Can you rebase?

There were two problems:
- The old things weren't removed, resulting in accumulation of duplicate things and comparing the new one against the old one resulting in erroneous update
-  Numeric values (usually entered as integer) in a newly loaded Channel Configuration properties are stored as BigDecimal with Scale 0, but subsequent normalization changed it to scale 1. This made equals() return false when it shouldn't. This leads to calling notifyListenersAboutUpdatedElement unnecessarily.

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
@jimtng jimtng force-pushed the things-reload-fix branch from 8a6ed12 to 23de094 Compare May 1, 2024 19:46
@jimtng
Copy link
Contributor Author

jimtng commented May 1, 2024

rebased

@jimtng jimtng changed the title Don't update unchanged things in .things file .things file: fix change detection May 1, 2024
@lolodomo
Copy link
Contributor

lolodomo commented May 1, 2024

Integration tests failed in org.openhab.core.automation.tests:
org.openhab.core.automation.internal.RuleEngineTest#testRuleConfigValue() <<< ERROR: Wrong config value ==> expected: <5> but was: <5.0>

jimtng added 3 commits May 2, 2024 07:39
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
@jimtng
Copy link
Contributor Author

jimtng commented May 2, 2024

checks passed now

@lolodomo
Copy link
Contributor

lolodomo commented May 2, 2024

Looks good.

Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

Thanks!

@J-N-K J-N-K merged commit eb23399 into openhab:main May 2, 2024
5 checks passed
@J-N-K J-N-K changed the title .things file: fix change detection Fix change detection for textual things May 2, 2024
@J-N-K J-N-K added this to the 4.2 milestone May 2, 2024
@jimtng jimtng deleted the things-reload-fix branch May 2, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Change loading mechanism for *.things and *.items files
3 participants