From cc3b0eebbb0efe44f5c5923e59fd88173a23f9fc Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Mon, 6 Apr 2026 21:55:02 +0200 Subject: [PATCH 1/4] [TIKA-4704] Implement pipes client shutdown in TikaGrpcServerImpl Added shutdown logic for pipes client in TikaGrpcServerImpl. --- .../org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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 c61085560b8..0dae8c458da 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 @@ -488,5 +488,14 @@ public void shutdown() { LOG.error("Error shutting down Ignite server", e); } } + if (pipesClient != null) { + LOG.info("Shutting down the pipes client"); + try { + pipesClient.close(); + } + catch (IOException e) { + LOG.error("Error closing the pipes client", e); + } + } } } From 3e1c2852776bca32a6cacdff7683690fa527eb03 Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Tue, 7 Apr 2026 05:14:34 +0200 Subject: [PATCH 2/4] Update tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 0dae8c458da..cee7036048c 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 @@ -492,9 +492,10 @@ public void shutdown() { LOG.info("Shutting down the pipes client"); try { pipesClient.close(); - } - catch (IOException e) { + } catch (IOException e) { LOG.error("Error closing the pipes client", e); + } finally { + pipesClient = null; } } } From eb2e5fd4989a61f8a31dada78bbb8064a8a0848d Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Tue, 7 Apr 2026 05:46:37 +0200 Subject: [PATCH 3/4] add postShutdown Ensure igniteStoreServer is set to null in finally block. --- .../org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 cee7036048c..8c6b96a4156 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,11 +483,18 @@ public void shutdown() { 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 { From 5d0c68ca2d9d9c51377512b702a002279af058c3 Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Tue, 7 Apr 2026 05:49:25 +0200 Subject: [PATCH 4/4] Call postShutdown method after server shutdown Invoke postShutdown on service implementation if not null. --- .../main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java | 3 +++ 1 file changed, 3 insertions(+) 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 a576ba22c2c..acbc1f4314e 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 void stop() throws InterruptedException { .shutdown() .awaitTermination(30, TimeUnit.SECONDS); } + if (serviceImpl != null) { + serviceImpl.postShutdown(); + } } /**