fix: set sms.createdBy consumer thread DHIS2-18187 [2.41] #18781
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
The UserDetails refactoring in 41 broke incoming SMS processing.
The sms processing code
dhis2-core/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/listener/CommandSMSListener.java
Line 241 in db185d6
IncomingSms
statedhis2-core/dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/hibernate/HibernateIdentifiableObjectStore.java
Lines 173 to 175 in db185d6
Fix
stream
instead ofparallelStream
as we would need to set the user on those threads as well. We used the same strategy on master in tracker. We are not sure how many people actually use the inbound sms feature in tracker.sms.createdBy
user when setting fields likestoredBy
as it contains the user that sent the sms found/set by theSmsInboundController.getUserByPhoneNumber
. The user that sent the sms is the one responsible for creating/updating/deleting events and other entities.dhis2-core/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/sms/SmsInboundController.java
Lines 102 to 120 in db185d6
Tests
I cannot backport the automated tests created on master during https://dhis2.atlassian.net/browse/DHIS2-17729. This would take weeks or more. I briefly tried backporting one but we cannot use controller tests as they cannot be non-transactional in 41. The sms are consumed in another thread so we have the issue of the test transaction isolating us from that thread.
Manual tests