Verify device is opened and claimed before health check (#10)#94
Open
ba-00001 wants to merge 3 commits into
Open
Verify device is opened and claimed before health check (#10)#94ba-00001 wants to merge 3 commits into
ba-00001 wants to merge 3 commits into
Conversation
Health endpoints previously failed when called before a device was opened and claimed. getHealth() now checks device state first: if the device is not both opened and claimed it immediately returns NOT_READY and skips the health check; only an opened+claimed device proceeds to the health check. - DynamicDevice: add isOpened()/isClaimed(); isConnected() composes them - All device classes expose isOpened()/isClaimed() - All device managers gate getHealth() on opened+claimed - Add DynamicDeviceTest and per-manager gate tests
SimulatedDynamicDevice overrides isConnected() but not the new isOpened()/isClaimed(), so in simulation mode the health gate read the underlying JavaPOS control (never opened/claimed) and forced NOT_READY for scanner/printer/scale/cash drawer. Override isOpened()/isClaimed() to track the simulated connection state.
For printer, scale, and cash drawer, isConnected() returns a cached connection flag while isOpened()/isClaimed() read live JPOS state, so a transient getClaimed() failure could flip a healthy device to NOT_READY. These devices only track a single connection flag (set after a successful open + claim + enable), so make isOpened()/isClaimed() mirror isConnected(). Scanner, line display, and MICR keep delegating to the dynamic device, where all three already read the same live state.
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.
Fixes #10.
Health endpoints could fail when called before a device was opened and claimed. Each device manager's getHealth() now checks state first: if the device is not both opened and claimed it returns NOT_READY and skips the health check; only an opened+claimed device proceeds.