Skip to content

[MS-1444] Reset accumulators upon scanner disconnect to prevent lefto…#1680

Merged
luhmirin-s merged 2 commits into
release/2026.2.0from
MS-1444-Impossible-to-scan-fingerprints-with-Galaxy-J6
May 27, 2026
Merged

[MS-1444] Reset accumulators upon scanner disconnect to prevent lefto…#1680
luhmirin-s merged 2 commits into
release/2026.2.0from
MS-1444-Impossible-to-scan-fingerprints-with-Galaxy-J6

Conversation

@BurningAXE
Copy link
Copy Markdown
Contributor

@BurningAXE BurningAXE commented May 26, 2026

…ver bytes from corrupting parsing on next connection

JIRA ticket
Will be released in: 2026.2.0

Root cause analysis (for bugfixes only)

First known affected version: since forever

  • See ticket for reproduction steps
  • What happens upon timeout is that the Accumulator's buffer is not cleared so there are some leftover bytes from the previous connection when a new one is established. This leads to parsing errors that then lead to consistent timeouts and reconnections. Since the whole thing is a singleton, the only way to recover is to kill the app.

Notable changes

  • Added an explicit reset in the Accumulator that is called upon disconnect. This should be safe since there is no use case where we want state preservation through reconnects.

Testing guidance

  • Test a few normal/happy paths
  • Check out the ticket for reproduction steps of the bug

Additional work checklist

  • Effect on other features and security has been considered
  • Design document marked as "In development" (if applicable)
  • External (Gitbook) and internal (Confluence) Documentation is up to date (or ticket created)
  • Test cases in Testiny are up to date (or ticket created)
  • Other teams notified about the changes (if applicable)

…ver bytes from corrupting parsing on next connection
@cla-bot cla-bot Bot added the ... label May 26, 2026
@BurningAXE BurningAXE requested a review from Copilot May 26, 2026 09:47
@BurningAXE BurningAXE marked this pull request as draft May 26, 2026 09:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a scanner reconnection edge case in the fingerprint scanner v2 pipeline by ensuring accumulator state is cleared on disconnect, preventing partial/leftover bytes from corrupting parsing after a reconnect.

Changes:

  • Add a reset() API to the generic Accumulator to restore its initial empty state.
  • Invoke accumulator resets during disconnect flows in RootMessageInputStream, PacketRouter, and MainMessageInputStream.
  • Add/extend unit tests to validate resets happen on disconnect and that reset prevents partial-header contamination.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
fingerprint/infra/scanner/src/test/java/com/simprints/fingerprint/infra/scanner/v2/tools/accumulator/AccumulatorTest.kt Adds coverage proving reset() clears partial state so subsequent elements parse correctly.
fingerprint/infra/scanner/src/test/java/com/simprints/fingerprint/infra/scanner/v2/incoming/root/RootMessageInputStreamTest.kt Verifies root accumulator is reset on disconnect.
fingerprint/infra/scanner/src/test/java/com/simprints/fingerprint/infra/scanner/v2/incoming/main/packet/PacketRouterTest.kt Verifies packet accumulator is reset on disconnect.
fingerprint/infra/scanner/src/test/java/com/simprints/fingerprint/infra/scanner/v2/incoming/main/MainMessageInputStreamTest.kt Verifies all main-mode message accumulators are reset on disconnect.
fingerprint/infra/scanner/src/main/java/com/simprints/fingerprint/infra/scanner/v2/tools/accumulator/Accumulator.kt Introduces reset() and stores the initial collection to support resetting.
fingerprint/infra/scanner/src/main/java/com/simprints/fingerprint/infra/scanner/v2/incoming/root/RootMessageInputStream.kt Resets root response accumulator on disconnect.
fingerprint/infra/scanner/src/main/java/com/simprints/fingerprint/infra/scanner/v2/incoming/main/packet/PacketRouter.kt Resets byte-array-to-packet accumulator on disconnect.
fingerprint/infra/scanner/src/main/java/com/simprints/fingerprint/infra/scanner/v2/incoming/main/MainMessageInputStream.kt Resets all message accumulators on disconnect in addition to disconnecting the packet router.

@BurningAXE BurningAXE marked this pull request as ready for review May 26, 2026 14:02
@BurningAXE BurningAXE requested review from a team, TristramN, alex-vt, alexandr-simprints, meladRaouf and ybourgery and removed request for a team May 26, 2026 14:02
@sonarqubecloud
Copy link
Copy Markdown

@luhmirin-s luhmirin-s merged commit 508d699 into release/2026.2.0 May 27, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants