The PR for the invoice preview service needs to be checked. The feature assembles an HTML preview from a list of lines, writes it to a temporary file, and closes all related resources. It is expected that on a repeated call with the same invoiceId, the service does not create duplicate tasks, and that the temporary file is always removed after the operation completes, even if preview generation fails.
Runtime environment: Java 21, standard library. Run: standard javac/java without additional dependencies. Verification format: review the diff and point out issues in the changed files. It is assumed that the service is called sequentially in a single JVM process.
API contract:
PreviewService.generate(InvoiceRequest request) returns CompletionStage<PreviewResult>.invoiceId should be treated as a duplicate.Reproduction:
invoiceId.Assumptions:
Files.createTempFile.Java 21, standard library only; compile and run with javac --release 21 and java
Use line comments to explain the problem, its impact, the fix and how to test it.