Skip to content

Fix concurrency, logging, and error handling issues (#1988, #1989, #1991, #1995) - #2116

Open
slachiewicz wants to merge 3 commits into
apache:masterfrom
slachiewicz:fix/audit-bugs-1988-1989-1991-1995
Open

Fix concurrency, logging, and error handling issues (#1988, #1989, #1991, #1995)#2116
slachiewicz wants to merge 3 commits into
apache:masterfrom
slachiewicz:fix/audit-bugs-1988-1989-1991-1995

Conversation

@slachiewicz

Copy link
Copy Markdown
Member

Summary of Changes

This PR addresses four open defects identified during the code audit:

  1. #1988: In PutTaskRequestContent.java, change catch (Throwable t) to catch (Exception t) at lines 246 and 298. Catching Throwable trapped JVM fatal errors (OutOfMemoryError, StackOverflowError, LinkageError) and wrapped them into failed content chunks rather than letting them propagate for proper diagnostics.
  2. #1989: In IpcServer.java, replace direct System.out / System.err console writes with standard SLF4J Logger (LOGGER.debug, LOGGER.info, LOGGER.error), ensuring server output integrates with standard logging configurations.
  3. #1991: In IpcClient.java, synchronize retrieval and operations on volatile fields (output, input, socket) to prevent race conditions and NPEs when close() is invoked concurrently with active send() or receive().
  4. #1995: In CollectResult.java, back exceptions and cycles collections with CopyOnWriteArrayList and add thread-safe accessors (setExceptions, setCycles), ensuring thread-safe access during multi-threaded dependency collection (such as in BfDependencyCollector).

Verification

  • mvn test -pl maven-resolver-transport-jetty,maven-resolver-named-locks-ipc,maven-resolver-api,maven-resolver-impl passed with 781 tests, 0 failures, 0 errors.
  • Checkstyle and Spotless verified clean.

This change was created with AI assistance.

@slachiewicz slachiewicz added bug Something isn't working maintenance labels Sep 4, 2026
@slachiewicz slachiewicz added this to the 2.0.23 milestone Sep 4, 2026
@cstamas

cstamas commented Sep 4, 2026

Copy link
Copy Markdown
Member

Can we get the build green?

@slachiewicz
slachiewicz force-pushed the fix/audit-bugs-1988-1989-1991-1995 branch from ee4724b to 4b1572c Compare September 4, 2026 19:57
@slachiewicz

Copy link
Copy Markdown
Member Author

Dropped the [#1989] commit; the other three are unchanged. IpcAdapterIT and IpcAdapterNoForkIT were failing on every OS and JDK because of it.

IpcClient forks the daemon with a two-jar classpath built from getJarPath(getClass()) + getJarPath(IpcServer.class), both of which resolve to maven-resolver-named-locks-ipc itself. SLF4J is not on it, so the static LOGGER field failed during class initialisation in the forked JVM:

$ java -cp maven-resolver-named-locks-ipc/target/classes org.eclipse.aether.named.ipc.IpcServer
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at org.eclipse.aether.named.ipc.IpcServer.<clinit>(IpcServer.java:52)

The daemon died before it could connect back, the client's future.get(5, TimeUnit.SECONDS) expired, and every lock operation surfaced as RuntimeException: Unable to create new sync context.

#1989 is not reachable by adding the dependency either: the fork would also need an SLF4J binding, and without one the daemon logs nothing. System.out is the working channel here, since IpcClient already redirects the daemon's output to resolver-ipcsync-<id>.log via ProcessBuilder.Redirect. Reopening #1989 would need the classpath question settled first.

Verified: IpcAdapterIT 9 tests, 0 failures, 0 errors, where it was 5 failures and 4 errors before; full build 2055 tests, 0 failures, 0 errors.

This comment was created with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants