This is an automated email from the ASF dual-hosted git repository.

tilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/main by this push:
     new 27ba181359 [TIKA-4704] Implement pipes client shutdown to reduce temp 
directory leak
27ba181359 is described below

commit 27ba1813595458356d0e494232074ec760c5dd5e
Author: Tilman Hausherr <[email protected]>
AuthorDate: Tue Apr 7 06:25:16 2026 +0200

    [TIKA-4704] Implement pipes client shutdown to reduce temp directory leak
    
    * [TIKA-4704] Implement pipes client shutdown in TikaGrpcServerImpl
    
    Added shutdown logic for pipes client in TikaGrpcServerImpl.
    
    * Update 
tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
    
    Co-authored-by: Copilot <[email protected]>
    
    * add postShutdown
    
    Ensure igniteStoreServer is set to null in finally block.
    
    * Call postShutdown method after server shutdown
    
    Invoke postShutdown on service implementation if not null.
    
    ---------
    
    Co-authored-by: Copilot <[email protected]>
---
 .../org/apache/tika/pipes/grpc/TikaGrpcServer.java    |  3 +++
 .../apache/tika/pipes/grpc/TikaGrpcServerImpl.java    | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git 
a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java 
b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java
index a576ba22c2..acbc1f4314 100644
--- a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java
+++ b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java
@@ -128,6 +128,9 @@ public class TikaGrpcServer {
                     .shutdown()
                     .awaitTermination(30, TimeUnit.SECONDS);
         }
+        if (serviceImpl != null) {
+            serviceImpl.postShutdown();
+        }
     }
 
     /**
diff --git 
a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java 
b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
index c61085560b..8c6b96a415 100644
--- a/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
+++ b/tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java
@@ -483,9 +483,26 @@ class TikaGrpcServerImpl extends TikaGrpc.TikaImplBase {
             LOG.info("Shutting down embedded Ignite server");
             try {
                 igniteStoreServer.close();
-                igniteStoreServer = null;
             } catch (Exception e) {
                 LOG.error("Error shutting down Ignite server", e);
+            } finally {
+                igniteStoreServer = null;
+            }
+        }
+    }
+
+    /**
+     * Close the pipe client, to be called after TikaGrpcServer has shut down.
+     */
+    void postShutdown() {
+        if (pipesClient != null) {
+            LOG.info("Shutting down the pipes client");
+            try {
+                pipesClient.close();
+            } catch (IOException e) {
+                LOG.error("Error closing the pipes client", e);
+            } finally {
+                pipesClient = null;
             }
         }
     }

Reply via email to