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

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

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


##########
tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java:
##########
@@ -128,6 +128,9 @@ public void stop() throws InterruptedException {
                     .shutdown()
                     .awaitTermination(30, TimeUnit.SECONDS);
         }

Review Comment:
   `Server.awaitTermination(30, TimeUnit.SECONDS)` returns after the timeout 
even if the server is still running; because the return value is ignored, 
`postShutdown()` (which closes `pipesClient`) may run while RPCs are still 
in-flight. Consider checking the boolean result and only closing `pipesClient` 
once termination has actually occurred (or call `shutdownNow()`/wait longer 
when the graceful shutdown times out).



##########
tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java:
##########
@@ -128,6 +128,9 @@ public void stop() throws InterruptedException {
                     .shutdown()
                     .awaitTermination(30, TimeUnit.SECONDS);
         }
+        if (serviceImpl != null) {
+            serviceImpl.postShutdown();
+        }

Review Comment:
   If `stop()` is interrupted during `awaitTermination(...)`, it will throw 
`InterruptedException` and skip `postShutdown()`, leaving the `pipesClient` 
open. Consider ensuring `postShutdown()` runs from a `finally` block (and 
re-interrupting the thread if needed) so resources are consistently cleaned up.





> 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