-
Notifications
You must be signed in to change notification settings - Fork 356
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: identify classes with an Integer ID field [DHIS2-16092] #15554
Conversation
…validation system
Codecov Report
@@ Coverage Diff @@
## master #15554 +/- ##
=============================================
+ Coverage 49.45% 66.19% +16.73%
- Complexity 23282 31225 +7943
=============================================
Files 3485 3485
Lines 129758 129762 +4
Branches 15141 15141
=============================================
+ Hits 64174 85895 +21721
+ Misses 59514 36777 -22737
- Partials 6070 7090 +1020
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1223 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
...alidation/src/main/java/org/hisp/dhis/cacheinvalidation/redis/CacheInvalidationListener.java
Dismissed
Show dismissed
Hide dismissed
Kudos, SonarCloud Quality Gate passed! |
} catch (NoSuchFieldException e) { | ||
// Ignore this exception, as it's expected unless it's a class with an int ID. | ||
} | ||
// In most cases the ID will be a long. | ||
return Long.parseLong(idPart); |
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.
It looks like if there is no id
field and the NoSuchFieldException
is thrown that we still try parse the idPart
as a long even though there is no id
field. Is that what we want to try here?
Some tests for this logic would be beneficial I think, with so many conditional branches in this method.
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.
My thinking here is that if there is an ID field on the class it will be an Integer. If you do a search for "int id;" you will see the result is only classes that has the ID field on the actual class and don't inherit it from the superclass. So when it's not an int field, it will be a Long, mostly via the BaseIdentifiableObject. Making logic to catch every single case here is not the intention.
…validation system (#15554) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
…validation system (#15554) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
…validation system (#15554) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
…validation system (#15554) (#15571) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
…validation system (#15554) (#15569) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
…validation system (#15554) (#15570) Co-authored-by: Morten Hansen <[email protected]> (cherry picked from commit d72d3d4)
Summary
Manual test for bug/issue
Automatic tests
N/A
Jira
DHIS2-16092