[ 
https://issues.apache.org/jira/browse/TIKA-4704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18071287#comment-18071287
 ] 

ASF GitHub Bot commented on TIKA-4704:
--------------------------------------

Copilot commented on code in PR #2735:
URL: https://github.com/apache/tika/pull/2735#discussion_r3037161116


##########
tika-server/tika-server-standard/src/test/java/org/apache/tika/server/standard/UnpackerResourceWithConfigTest.java:
##########
@@ -260,4 +262,12 @@ public void testPDFPerPageRenderGray() throws Exception {
             assertTrue(averageColor.getBlue() < 100 && averageColor.getBlue() 
> 90);
         }
     }
+    
+    @AfterAll
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (unpackTempDir != null && Files.exists(unpackTempDir)) {
+            FileUtils.deleteQuietly(unpackTempDir.toFile());

Review Comment:
   `FileUtils.deleteQuietly(...)` will silently ignore failures, which can 
leave the temp unpack directory behind with no signal (potentially defeating 
the purpose of TIKA-4704). Consider using `FileUtils.deleteDirectory(...)` (or 
catching/logging any IOException) so cleanup failures are visible and 
consistent with other tests in this module (e.g., `TikaPipesTest`). Also, 
adding `@Override` here would make it explicit that this method overrides 
`CXFTestBase#tearDown`.
   ```suggestion
       @Override
       public void tearDown() throws Exception {
           super.tearDown();
           if (unpackTempDir != null && Files.exists(unpackTempDir)) {
               FileUtils.deleteDirectory(unpackTempDir.toFile());
   ```





> Avoid remaining temp files
> --------------------------
>
>                 Key: TIKA-4704
>                 URL: https://issues.apache.org/jira/browse/TIKA-4704
>             Project: Tika
>          Issue Type: Task
>    Affects Versions: 3.3.0
>            Reporter: Tilman Hausherr
>            Priority: Minor
>             Fix For: 4.0.0, 3.3.1
>
>         Attachments: screenshot-1.png
>
>
> This is my temp directory after a successful build of tika 3. We should try 
> to lessen this.
>  !screenshot-1.png! 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to