Skip to content

Add state validation and interruption handling to AbstractProducer.run()#147

Merged
bernardladenthin merged 1 commit intomainfrom
claude/fix-produceropenCL-init-ISA9y
Mar 23, 2026
Merged

Add state validation and interruption handling to AbstractProducer.run()#147
bernardladenthin merged 1 commit intomainfrom
claude/fix-produceropenCL-init-ISA9y

Conversation

@bernardladenthin
Copy link
Copy Markdown
Owner

Summary

This change adds defensive checks to the AbstractProducer.run() method to validate the producer's state before execution and gracefully handle interruptions that occur before the producer starts running.

Key Changes

  • State validation: Added a check to ensure the producer is in the INITIALIZED state before running. If not, an IllegalStateException is thrown with a descriptive message.
  • Interruption handling: Added logic to detect if the producer was interrupted before it started running (via shouldRun flag). If interrupted, the producer logs an info message and sets its state to NOT_RUNNING before returning early.
  • Test coverage: Added two new test cases:
    • run_notInitialized_illegalStateExceptionThrown(): Verifies that calling run() without initialization throws IllegalStateException
    • run_interruptedBeforeStarted_stateSetToNotRunning(): Verifies that if a producer is interrupted before starting, it properly logs the event and transitions to NOT_RUNNING state

Implementation Details

The validation checks are performed at the beginning of the run() method before the main execution loop, ensuring that invalid states are caught early and the producer behaves predictably in edge cases.

https://claude.ai/code/session_017zaPZjBcrkXejsmU8h5F9r

…xecution

Add two guards at the start of run(): (1) check shouldRun to handle the
case where interrupt() is called before the executor thread starts, and
(2) verify state is INITIALIZED to prevent producing keys without proper
initialization. This fixes a sporadic IllegalStateException in
ProducerOpenCL where the OpenCL context could be null if releaseProducer()
ran before the executor thread started.

https://claude.ai/code/session_017zaPZjBcrkXejsmU8h5F9r
@sonarqubecloud
Copy link
Copy Markdown

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.54%. Comparing base (f34ca46) to head (f4606dd).

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #147      +/-   ##
============================================
+ Coverage     74.40%   74.54%   +0.14%     
- Complexity      559      562       +3     
============================================
  Files            84       84              
  Lines          2422     2428       +6     
  Branches        207      208       +1     
============================================
+ Hits           1802     1810       +8     
+ Misses          564      563       -1     
+ Partials         56       55       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bernardladenthin bernardladenthin merged commit 71fd6a0 into main Mar 23, 2026
8 checks passed
@bernardladenthin bernardladenthin deleted the claude/fix-produceropenCL-init-ISA9y branch April 1, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants