A PR landed in the CLI utility for local report processing with changes to exporting data into a temporary file. A code review is needed to find behavioral defects.
Context and requirements:
ReportExporter.exportCsv(List<String> rows).rows strings into it, one line per record;IOException must be thrown.readBack(Path file) is extensible and may throw IOException even after a successful write, for example in a test stub.What needs to be done:
exportCsv(List<String> rows).Reproduction steps:
exportCsv(List.of("a", "b")) should return a string with two CSV lines and leave no temporary file behind.null; writing should fail and leave no temporary file behind.readBack(...) so that it throws IOException; the temporary file must still be deleted.Java 21, standard library, code is compiled with javac and run as a regular CLI process without extra dependencies. To verify the read-error scenario, it is enough to create a ReportExporter subclass in the same package and override readBack(Path).
Use line comments to explain the problem, its impact, the fix and how to test it.