elharo opened a new pull request, #1348:
URL: https://github.com/apache/maven-assembly-plugin/pull/1348

   ## Summary
   
   Fixes apache/maven-assembly-plugin#1275.
   
   `AbstractLineAggregatingHandler.addToArchive` wrapped the aggregation output 
stream in a `PrintWriter`. By design, `PrintWriter` catches `IOException` 
internally and only records it via `checkError()`. Any write failure during 
aggregation was therefore silently swallowed, and a truncated or empty 
aggregated file was added to the archive without any error surfacing.
   
   ## Changes
   
   - Replaced `PrintWriter` with `OutputStreamWriter` in 
`AbstractLineAggregatingHandler.addToArchive`. Write failures now propagate as 
`IOException` and are wrapped in an `ArchiverException` by the existing catch 
block.
   - Added a small `protected` seam `newAggregationOutputStream(Path)` so the 
write target can be replaced in tests.
   - Added regression test 
`AbstractLineAggregatingHandlerTest.addToArchiveShouldPropagateIOExceptionWhenAggregationWriteFails`
 that injects an `OutputStream` which fails on write and asserts that 
`addToArchive` throws `ArchiverException`.
   
   The test fails on the old code (`PrintWriter` swallows the exception, 
nothing is thrown) and passes with the fix.
   
   `DefaultMessageHolder` also uses `PrintWriter`, but it wraps an in-memory 
`StringWriter` which cannot throw `IOException`; it is left unchanged (and 
`Throwable.printStackTrace` requires a `PrintWriter`).
   
   ## Verification
   
   - `mvn verify`: BUILD SUCCESS, 269 tests pass (1 new regression test).
   - Behavior of the success path is unchanged: lines are written followed by 
the platform line separator, identical to the previous `println` behavior.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to