(fix) O3-5644: Use APIException with translatable message code for queue entry concurrency errors#112
Open
sanks011 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates queue entry optimistic-locking/concurrency error handling so REST clients can receive translatable, message-code-based errors instead of raw English IllegalStateException strings.
Changes:
- Replace concurrency-related
IllegalStateExceptionthrows withAPIExceptionusing a message code intransitionQueueEntry()andundoTransition(). - Add a new message key
queue.entry.error.concurrentModificationtomessages.properties. - Update unit tests to expect
APIExceptionfor these concurrency cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| api/src/main/java/org/openmrs/module/queue/api/impl/QueueEntryServiceImpl.java | Switch concurrency error throws to APIException with a translatable message code; remove one stale TODO comment. |
| api/src/main/resources/messages.properties | Add the new message key for concurrent modification errors. |
| api/src/test/java/org/openmrs/module/queue/api/QueueEntryServiceTest.java | Update tests to expect APIException and add the needed import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… concurrency errors Replace raw IllegalStateException with APIException using a translatable message code (queue.entry.error.concurrentModification) for optimistic locking failures in transitionQueueEntry() and undoTransition(). This enables the RESTWS-1002 translatedMessage field to automatically provide localized error messages. Also removes a stale TODO referencing cancelled ticket O3-2988.
c3dd523 to
d6bb511
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Summary
The optimistic locking checks in
QueueEntryServiceImpl.transitionQueueEntry()andundoTransition()currently throw a rawIllegalStateException("Queue entry was modified by another transaction"). This has two issues:IllegalStateExceptionis not anAPIException, so the RESTWS-1002translatedMessagefield does not apply - the frontend receives an untranslated English string.messages.properties(e.g.queue.entry.duplicate.patient).Changes
IllegalStateException→APIException("queue.entry.error.concurrentModification", null)in bothtransitionQueueEntry()andundoTransition()queue.entry.error.concurrentModificationtomessages.propertiesAPIExceptionRelated Issue
https://issues.openmrs.org/browse/O3-5644