llama90 commented on code in PR #42038: URL: https://github.com/apache/arrow/pull/42038#discussion_r1638386051
########## java/adapter/avro/src/test/java/org/apache/arrow/adapter/avro/AvroToArrowIteratorTest.java: ########## Review Comment: I was getting an error in Windows saying "failed to delete temp directory" because "The process cannot access the file because it is being used by another process." - [Error Link](https://github.com/apache/arrow/actions/runs/9498747854/job/26178122374?pr=42038#step:5:2537) To fix this, I found out that using `try-with-resources` to properly close resources would help. But for the `convert` method, the `FileInputStream` (fis) needs to stay open for the `iterator` after the `convert` method is called. This caused the error because the `fis` wasn't properly closed. So, I made a `writeDataToFile` method for the `FileOutputStream` and used `try-with-resources` for `fis` in the same method where the `iterator` is used. Now, the tests run fine on Windows too. Here are the different approaches I tried: **Attempt 1:** convert method: - FileOutputStream with `try-with-resources` - FileInputStream with `try-with-resources` Error: `Stream Closed` - because the `fis` was closed while the `iterator` still needed it. **Attempt 2:** convert method: - FileOutputStream with `try-with-resources` - FileInputStream Error: `failed to delete temp directory` - because the `fis` wasn't closed. **Attempt 3:** convert method: - FileOutputStream with `try-with-resources` - Added `FileInputStream` as a parameter to the convert method and explicitly closed it in the test method. Didn't work as expected. -- 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]
