Wassim67 opened a new issue, #7684:
URL: https://github.com/apache/hop/issues/7684

   ### Apache Hop version?
   
   2.19.0-SNAPSHOT (`main`)
   
   ### Java version?
   
   OpenJDK 21
   
   ### Operating system
   
   Windows
   
   ### What happened?
   
   The ODS writer tests complete their functional assertions successfully, but 
JUnit fails while cleaning their `@TempDir` directories because the generated 
`.ods` files remain locked by the Java process.
   
   A single test reproduces the problem:
   
   ```text
   mvnw.cmd -pl plugins/transforms/excel 
-Dtest=OdsExcelWriterTest#testAutoSizeColumns test
   ```
   
   The test ends with:
   
   ```text
   Failed to delete temp directory
   FileSystemException: autosize.ods: The process cannot access the file 
because it is being used by another process
   ```
   
   Running the complete Excel module produces the same cleanup error for 12 ODS 
writer tests.
   
   ### Cause
   
   The affected tests load generated files using:
   
   ```java
   try (OdfSpreadsheetDocument document = 
OdfSpreadsheetDocument.loadDocument(outputFile)) {
     // assertions
   }
   ```
   
   With ODFDOM 0.8.7 on Windows, closing the `OdfSpreadsheetDocument` created 
through the `File` overload does not release the underlying file handle in time 
for JUnit's `@TempDir` cleanup.
   
   The production ODS writer closes its document and output streams correctly. 
The lock comes from the test verification reads.
   
   ### Verified fix
   
   Open the file through an explicitly managed input stream:
   
   ```java
   try (InputStream input = Files.newInputStream(outputFile.toPath());
       OdfSpreadsheetDocument document = 
OdfSpreadsheetDocument.loadDocument(input)) {
     // assertions
   }
   ```
   
   Results on Windows after applying this to the affected ODS tests:
   
   - ODS tests: 17 tests, 0 failures, 0 errors
   - Complete Excel module: 75 tests, 0 failures, 0 errors
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: Tests


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