GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug: fix IPC named lock client-side robustness for Windows by gnodet · Pull Request #1910 · apache/maven-resolver

Conversation

@gnodet

@gnodet gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes Windows CI flakiness in IpcNamedLockFactoryIT.exclusiveAccess() (seen in PR #1909, CI run 27139141318).

Root cause: When the loser thread's client.lock() times out in doLockExclusively(), the cleanup call client.unlock(contextId) could either:

  • Hang forever — it used Long.MAX_VALUE timeout, so if the server/receiver had any issue, the thread blocked indefinitely
  • Throw RuntimeException — which propagated out of Access.run() (which only catches InterruptedException), causing the thread to terminate without calling loser.countDown(). The winner thread then waited on loser.await() forever, and the test hung until Surefire killed it at 25 seconds.

Changes

  1. IpcNamedLock: Wrap cleanup unlock in tryUnlock() — a try-catch that swallows exceptions so the calling thread always returns false instead of crashing. This is the primary fix.

  2. IpcClient.unlock(): Replace Long.MAX_VALUE timeout with 10 seconds. Normal unlock round-trips complete in microseconds; 10 seconds is generous enough while preventing infinite hangs.

  3. IpcClient.stopServer(): Replace Long.MAX_VALUE timeout with 30 seconds.

  4. IpcClient.receive(): On empty response, complete the future exceptionally instead of throwing IllegalStateException — the old behavior killed the receiver thread, breaking all subsequent operations on the shared client.

  5. IpcClient.close(): Call close() on EOF so pending futures are properly cleaned up when the server disconnects, and reset the initialized flag to prevent stale state.

Test plan

  • All 27 IPC tests pass locally (unit + integration: IpcNamedLockFactoryIT, IpcAdapterNoForkIT, IpcAdapterIT)
  • Windows CI should no longer hang on exclusiveAccess

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet
Bug: fix IPC named lock client-side robustness for Windows
4dce03f
When lock acquisition times out in IpcNamedLock, the cleanup call to
client.unlock() could either hang forever (Long.MAX_VALUE timeout) or
throw RuntimeException. On Windows, where IPC socket behavior can
differ, this causes test threads to either block indefinitely or crash
without signaling their CountDownLatch, making the test appear to hang.

Four changes:

1. IpcNamedLock: wrap cleanup unlock in try-catch (tryUnlock) so that a
   failure during timeout handling returns false instead of crashing the
   calling thread. This is the primary fix for the exclusiveAccess test
   hang on Windows.

2. IpcClient.unlock/stopServer: replace Long.MAX_VALUE timeouts with
   bounded values (10s/30s) so operations fail fast when the server is
   unresponsive.

3. IpcClient.receive: complete the future exceptionally on empty
   responses instead of throwing, which would kill the receiver thread
   and break all subsequent operations on the shared client.

4. IpcClient.close: properly call close() on EOF to clean up pending
   futures, and reset the initialized flag to prevent stale state.
@gnodet gnodet mentioned this pull request Jun 8, 2026
Fix for ChainedWorkspaceReader #1909
Merged
@gnodet
gnodet requested a review from Copilot June 8, 2026 14:21
Copilot started reviewing on behalf of gnodet June 8, 2026 14:21
View session
Copilot AI reviewed Jun 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet

gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

retest

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet
Bug: fix race condition in IpcClient.send() causing NPE on Windows
1400efb
The send() method read the `output` field multiple times without holding
the same lock as close(Throwable), which nulls it under synchronized(this).
Between ensureInitialized() returning and reaching synchronized(output),
the receiver thread could close the connection and null out the field,
causing a NullPointerException at output.flush().

Fix by capturing the output field in a local variable immediately after
ensureInitialized(), checking for null, and using the local throughout
the synchronized block.
@gnodet

gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a fix for the remaining NPE race condition in IpcClient.send().

Root cause: The send() method read the output field multiple times without holding the same lock as close(Throwable), which nulls the field under synchronized(this). Between ensureInitialized() returning and reaching synchronized(output), the receiver thread could call close(Throwable) — setting output = null — causing a NullPointerException at output.flush().

Fix: Capture output in a local variable immediately after ensureInitialized(), check it for null (throwing IOException("Connection closed") if the connection was already torn down), and use the local variable for both the synchronized block and all writes within it. This eliminates the TOCTOU race between the field read and its use.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet

gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

/rerun

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet

gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Rerunning CI to gather additional Windows stability data.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet

gnodet commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

retest this please

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gnodet
ci: retrigger Windows CI validation (run 3/3)
a097248
cstamas
cstamas approved these changes Jun 8, 2026
View reviewed changes
@gnodet
gnodet merged commit 9975d78 into apache:master Jun 8, 2026
42 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot assigned gnodet Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

@gnodet Please assign appropriate label to PR according to the type of change.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added this to the 2.0.19 milestone Jun 8, 2026
@cstamas cstamas added the bug Something isn't working label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@cstamas cstamas cstamas approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

bug Something isn't working

Projects

None yet

Milestone

2.0.19

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gnodet @cstamas
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.