eclipse / kapua

Eclipse Public License 2.0
222 stars 160 forks source link

:bug: Avoid multiple GuiceLocator instances, and handle potential multiple KapuaMessageListeners #4066

Closed dseurotech closed 1 month ago

dseurotech commented 1 month ago

Should guicelocator fail at broker startup, multiple instances of (Kapua)MessageListener are istantiated, failing device login due to split request/response maps. In general, guice modules should avoid doing logic, and should avoid failing. Guice cannot guarantee that singleton objects previously instantiated are killed - which in some cases can be very distruptive. This pr both avoids multiple guiceLocator instantiation attempts within a single process, but also puts in place safeguards that ensure that message correlation will continue to work even if there are multiple (Kapua)MessageListener (possibly due to changes in the wiring).

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 10.52632% with 34 lines in your changes missing coverage. Please review.

Project coverage is 16.78%. Comparing base (296efcd) to head (fae4a63). Report is 4 commits behind head on develop.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/eclipse/kapua/pull/4066/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/4066?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) ```diff @@ Coverage Diff @@ ## develop #4066 +/- ## ============================================= - Coverage 16.79% 16.78% -0.01% Complexity 22 22 ============================================= Files 2008 2008 Lines 52210 52229 +19 Branches 4399 4401 +2 ============================================= - Hits 8770 8768 -2 - Misses 43044 43064 +20 - Partials 396 397 +1 ``` | [Files](https://app.codecov.io/gh/eclipse/kapua/pull/4066?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse) | Coverage Δ | | |---|---|---| | [...artemis/plugin/security/ArtemisSecurityModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=broker%2Fartemis%2Fplugin%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fbroker%2Fartemis%2Fplugin%2Fsecurity%2FArtemisSecurityModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-YnJva2VyL2FydGVtaXMvcGx1Z2luL3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvYnJva2VyL2FydGVtaXMvcGx1Z2luL3NlY3VyaXR5L0FydGVtaXNTZWN1cml0eU1vZHVsZS5qYXZh) | `0.00% <ø> (ø)` | | | [.../kapua/client/security/bean/ResponseContainer.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=client%2Fsecurity%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fclient%2Fsecurity%2Fbean%2FResponseContainer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y2xpZW50L3NlY3VyaXR5L3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY2xpZW50L3NlY3VyaXR5L2JlYW4vUmVzcG9uc2VDb250YWluZXIuamF2YQ==) | `0.00% <ø> (ø)` | | | [...java/org/eclipse/kapua/commons/jpa/DataSource.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fjpa%2FDataSource.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvanBhL0RhdGFTb3VyY2UuamF2YQ==) | `93.75% <ø> (ø)` | | | [...e/kapua/commons/jpa/KapuaEntityManagerFactory.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=commons%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fcommons%2Fjpa%2FKapuaEntityManagerFactory.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y29tbW9ucy9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2NvbW1vbnMvanBhL0thcHVhRW50aXR5TWFuYWdlckZhY3RvcnkuamF2YQ==) | `54.34% <ø> (ø)` | | | [.../eclipse/kapua/locator/KapuaLocatorErrorCodes.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Flocator%2FKapuaLocatorErrorCodes.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9sb2NhdG9yL0thcHVhTG9jYXRvckVycm9yQ29kZXMuamF2YQ==) | `100.00% <100.00%> (ø)` | | | [...se/kapua/client/security/ClientSecurityModule.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=client%2Fsecurity%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fclient%2Fsecurity%2FClientSecurityModule.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y2xpZW50L3NlY3VyaXR5L3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY2xpZW50L3NlY3VyaXR5L0NsaWVudFNlY3VyaXR5TW9kdWxlLmphdmE=) | `83.33% <0.00%> (-16.67%)` | :arrow_down: | | [...ua/client/security/ServiceClientMessagingImpl.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=client%2Fsecurity%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fclient%2Fsecurity%2FServiceClientMessagingImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y2xpZW50L3NlY3VyaXR5L3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY2xpZW50L3NlY3VyaXR5L1NlcnZpY2VDbGllbnRNZXNzYWdpbmdJbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | | | [.../eclipse/kapua/locator/guice/GuiceLocatorImpl.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=locator%2Fguice%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Flocator%2Fguice%2FGuiceLocatorImpl.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-bG9jYXRvci9ndWljZS9zcmMvbWFpbi9qYXZhL29yZy9lY2xpcHNlL2thcHVhL2xvY2F0b3IvZ3VpY2UvR3VpY2VMb2NhdG9ySW1wbC5qYXZh) | `84.25% <50.00%> (-5.01%)` | :arrow_down: | | [...n/java/org/eclipse/kapua/locator/KapuaLocator.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=service%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Flocator%2FKapuaLocator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-c2VydmljZS9hcGkvc3JjL21haW4vamF2YS9vcmcvZWNsaXBzZS9rYXB1YS9sb2NhdG9yL0thcHVhTG9jYXRvci5qYXZh) | `46.00% <0.00%> (-5.12%)` | :arrow_down: | | [...se/kapua/client/security/KapuaMessageListener.java](https://app.codecov.io/gh/eclipse/kapua/pull/4066?src=pr&el=tree&filepath=client%2Fsecurity%2Fsrc%2Fmain%2Fjava%2Forg%2Feclipse%2Fkapua%2Fclient%2Fsecurity%2FKapuaMessageListener.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse#diff-Y2xpZW50L3NlY3VyaXR5L3NyYy9tYWluL2phdmEvb3JnL2VjbGlwc2Uva2FwdWEvY2xpZW50L3NlY3VyaXR5L0thcHVhTWVzc2FnZUxpc3RlbmVyLmphdmE=) | `0.00% <0.00%> (ø)` | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/eclipse/kapua/pull/4066/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eclipse)