balodesecurity opened a new pull request, #8327:
URL: https://github.com/apache/hadoop/pull/8327

   ## Summary
   
   `PBImageXmlWriter` and `FileDistributionCalculator` in the Offline Image 
Viewer (OIV) currently accept a `PrintStream` and call `print()`/`println()`. 
`PrintStream` silently swallows `IOException`s — errors are only detectable 
after the fact via `checkError()`, which can miss failures entirely.
   
   This patch replaces `PrintStream` with `java.io.Writer` in both classes so 
that write errors propagate immediately as `IOException`.
   
   - Replace `PrintStream out` field with `Writer out` in `PBImageXmlWriter` 
and `FileDistributionCalculator`
   - Convert all `out.print(x)` → `out.write(x)` and `out.println(x)` → 
`out.write(x + "\n")`
   - Add `throws IOException` to private helper methods in `PBImageXmlWriter` 
that call `out.write()`
   - `OfflineImageViewerPB` bridges the gap by wrapping the output 
`PrintStream` in an `OutputStreamWriter` (with explicit `flush()` after 
`visit()` to drain the buffer)
   - Update all test call sites to pass `new OutputStreamWriter(ps, 
StandardCharsets.UTF_8)` instead of a raw `PrintStream`
   
   ## Test plan
   
   - [x] `TestOfflineImageViewer` — 29 tests pass (includes 
`testReverseXmlRoundTrip`, `testCorruptionDetection*`, 
`testOfflineImageViewerWithFormatOption`, `testFileDistributionCalculator*`)
   - [x] `TestOfflineImageViewerForAcl` — 3 tests pass
   - [x] `TestSnapshot#testOfflineImageViewer` — passes


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to