Skip to content

Minimum Spanning Tree 1.0.1: don't throw when cancelled right as the run starts - #377

Merged
mbastian merged 1 commit into
master-forgefrom
fix/spanning-tree-cancel
Nov 8, 2026
Merged

mbastian merged 1 commit into
master-forgefrom
fix/spanning-tree-cancel

Conversation

@mbastian

@mbastian mbastian commented Nov 8, 2026

Copy link
Copy Markdown
Member

Seen in the first CI run of the SPI contract tests on master-forge (#376): the cancellation test, which cancels from another thread right after the run starts, printed

Exception in thread "Thread-1" java.lang.NullPointerException: Cannot invoke "MinimumSpanningTreeAlgorithm.cancel()" because "this.stAlgorithm" is null

MinimumSpanningTree.cancel() delegates to stAlgorithm, which execute() only creates when the run starts. A cancel that lands just before that (the user can click at any moment) threw. It's a race, so it shows up on slower machines.

  • cancel() returns false when there is no algorithm yet, instead of throwing.
  • stAlgorithm is volatile: it is written by the thread running the statistics and read when cancelling from another.
  • Version 1.0.0 → 1.0.1.

Verified: the contract tests (gephi-plugins-tests 1.2.1-SNAPSHOT) pass on this module. The race doesn't fire on a fast local machine, so the fix itself is by inspection. Short-lived branch off master-forge, 2 files.

🤖 Generated with Claude Code

cancel() delegated to an algorithm that is only created by execute(), so a cancel landing just after the run started threw a NullPointerException. Return false when there is no algorithm yet, and make the field volatile since it is set by the thread running the statistics and read when cancelling from another. Version 1.0.1.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@mbastian
mbastian merged commit 2a96070 into master-forge Nov 8, 2026
2 checks passed
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.

1 participant