eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

FIX - Problem of wrong serialization of ComposedKey fields on the cache #4032

Closed Agnul97 closed 4 months ago

Agnul97 commented 4 months ago

I discovered a bug regarding our use of ComposedKey classes and the serialization of some of their fields in the context of the Caching mechanism. One of its fields (scopeId) is of type KapuaId. The problem is that sometimes we create ComposedKeys using a ScopeId instance and then we try to perform a lookup of the same cache entry but using a KapuaEid. If this doesn’t seem a problem from an object-oriented perspective, considering that they have the same internal Id and the equals method would return true, it is from a “serialization” for the cache perspective, because the serialization of the 2 fields is different and, as so, the lookup cannot behave as want.

I fixed the issue in the constructor of the ComposedKey class casting the various KapuaId passed in input to be a fixed KapuaEid

codecov-commenter commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 16.80%. Comparing base (f33457d) to head (6c6d62b). Report is 12 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4032/graphs/tree.svg?width=650&height=150&src=pr&token=1P4N4CApH8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)](https://app.codecov.io/gh/eclipse/kapua/pull/4032?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4032 +/- ## ========================================== Coverage 16.80% 16.80% Complexity 10 10 ========================================== Files 1987 1987 Lines 51855 51855 Branches 4424 4424 ========================================== Hits 8716 8716 Misses 42736 42736 Partials 403 403 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4032?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [...ua/commons/service/internal/cache/ComposedKey.java](https://app.codecov.io/gh/eclipse/kapua/pull/4032?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fservice%2Finternal%2Fcache%2FComposedKey.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvc2VydmljZS9pbnRlcm5hbC9jYWNoZS9Db21wb3NlZEtleS5qYXZh) | `94.11% <100.00%> (ø)` | | | [...ua/commons/service/internal/cache/EntityCache.java](https://app.codecov.io/gh/eclipse/kapua/pull/4032?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fservice%2Finternal%2Fcache%2FEntityCache.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvc2VydmljZS9pbnRlcm5hbC9jYWNoZS9FbnRpdHlDYWNoZS5qYXZh) | `22.78% <ø> (ø)` | |