fix: readiness gate blocks tools until import and build complete (#27, #28) #41

Merged
fred merged 1 commit from fix/27-28-readiness-gate into main 2026-03-08 11:00:31 +00:00
Collaborator

Summary

  • #27 Auto-Build: After project import, enables auto-building and triggers an explicit IncrementalProjectBuilder.INCREMENTAL_BUILD to ensure the JDT index is fully built before tools execute
  • #28 Race Condition: Replaces AtomicBoolean with CountDownLatch in HeadlessApplication and adds a readiness gate in McpProtocolHandler.handleToolsCall() that blocks tool execution until import + build are complete
  • Metadata tools (jdt_get_version, jdt_list_projects, jdt_import_project) are exempt and can run during import
  • 5 minute timeout prevents indefinite blocking

Changes

File Change
HeadlessApplication.java CountDownLatch + awaitReady() API, auto-build + explicit workspace build after import
McpProtocolHandler.java Readiness gate before tool dispatch, isImportSafeTool() whitelist

Note on #29

Issue #29 (Virtual vs Non-Virtual Method Processor) is already implemented in RefactoringTools.java (lines 1577-1611) — can be closed.

Test plan

  • Start server in a project directory, call jdt_list_projects immediately → should return with status: importing
  • Call jdt_find_references during import → should block and succeed after import completes
  • Verify log shows: auto-building enabled, workspace build completed, ready for requests
  • Smoke tests: tests/smoke-test.sh
## Summary - **#27 Auto-Build**: After project import, enables auto-building and triggers an explicit `IncrementalProjectBuilder.INCREMENTAL_BUILD` to ensure the JDT index is fully built before tools execute - **#28 Race Condition**: Replaces `AtomicBoolean` with `CountDownLatch` in `HeadlessApplication` and adds a readiness gate in `McpProtocolHandler.handleToolsCall()` that blocks tool execution until import + build are complete - Metadata tools (`jdt_get_version`, `jdt_list_projects`, `jdt_import_project`) are exempt and can run during import - 5 minute timeout prevents indefinite blocking ## Changes | File | Change | |------|--------| | `HeadlessApplication.java` | `CountDownLatch` + `awaitReady()` API, auto-build + explicit workspace build after import | | `McpProtocolHandler.java` | Readiness gate before tool dispatch, `isImportSafeTool()` whitelist | ## Note on #29 Issue #29 (Virtual vs Non-Virtual Method Processor) is already implemented in `RefactoringTools.java` (lines 1577-1611) — can be closed. ## Test plan - [ ] Start server in a project directory, call `jdt_list_projects` immediately → should return with `status: importing` - [ ] Call `jdt_find_references` during import → should block and succeed after import completes - [ ] Verify log shows: auto-building enabled, workspace build completed, ready for requests - [ ] Smoke tests: `tests/smoke-test.sh`
fix: readiness gate blocks tools until import and build complete (#27, #28)
All checks were successful
Build and Release / build (push) Successful in 4m55s
2dc629135c
- Replace AtomicBoolean with CountDownLatch for proper blocking semantics
- Enable auto-building and trigger explicit workspace build after import (#27)
- Block tool execution in McpProtocolHandler until ready (#28)
- Allow metadata tools (jdt_get_version, jdt_list_projects, jdt_import_project)
  to run during import
- 5 minute timeout prevents indefinite blocking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fred merged commit 2dc629135c into main 2026-03-08 11:00:31 +00:00
fred deleted branch fix/27-28-readiness-gate 2026-03-08 11:00:31 +00:00
Sign in to join this conversation.
No description provided.