Replace printStackTrace with proper error handling#2011
Open
elharo wants to merge 2 commits into
Open
Conversation
elharo
commented
Jul 23, 2026
| result.setFile(TestFileUtils.createTempFile("")); | ||
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| throw new RuntimeException(e); |
Contributor
Author
There was a problem hiding this comment.
no catch is needed here and below. Just let the IOException bubble up and fail the test so you don't have to wrap the exception.
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #1999 by eliminating printStackTrace() usage in tests and tightening failure behavior, while also adjusting dependency collection bookkeeping during concurrent graph collection.
Changes:
- Replace
printStackTrace()inDefaultArtifactResolverTestwith exceptions that fail the test path on unexpectedIOException. - Remove
printStackTrace()from concurrency tests that already capture errors viaAtomicReference. - Introduce local counters in
DependencyCollectorDelegate.Resultsto avoid relying onCollectResultlist sizes while enforcing max exception/cycle limits.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| maven-resolver-impl/src/test/java/org/eclipse/aether/internal/impl/DefaultArtifactResolverTest.java | Converts temp-file IOException handling from printing to throwing so tests fail fast. |
| maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/collect/DependencyCollectorDelegate.java | Adds internal counters for exception/cycle limit checks during collection. |
| maven-resolver-api/src/test/java/org/eclipse/aether/DefaultSessionDataTest.java | Removes printStackTrace() from concurrency test worker threads. |
| maven-resolver-api/src/test/java/org/eclipse/aether/DefaultRepositoryCacheTest.java | Removes printStackTrace() from concurrency test worker threads. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
113
to
118
| try { | ||
| set(key, Boolean.TRUE); | ||
| assertEquals(Boolean.TRUE, get(key)); | ||
| } catch (Throwable t) { | ||
| error.compareAndSet(null, t); | ||
| t.printStackTrace(); | ||
| } |
Comment on lines
77
to
82
| try { | ||
| put(key, Boolean.TRUE); | ||
| assertEquals(Boolean.TRUE, get(key)); | ||
| } catch (Throwable t) { | ||
| error.compareAndSet(null, t); | ||
| t.printStackTrace(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1999
Changes:
e.printStackTrace()withthrow new RuntimeException(e)so tests properly fail on IO errors instead of silently printingt.printStackTrace()— error already captured in AtomicReference and assertedresult.getExceptions().size()/result.getCycles().size()for thread safety during concurrent collection