Skip to content

Commit 27ba181

Browse files
THausherrCopilot
andauthored
[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 <175728472+Copilot@users.noreply.github.com> * 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 <175728472+Copilot@users.noreply.github.com>
1 parent 4a65796 commit 27ba181

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ public void stop() throws InterruptedException {
128128
.shutdown()
129129
.awaitTermination(30, TimeUnit.SECONDS);
130130
}
131+
if (serviceImpl != null) {
132+
serviceImpl.postShutdown();
133+
}
131134
}
132135

133136
/**

tika-grpc/src/main/java/org/apache/tika/pipes/grpc/TikaGrpcServerImpl.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,26 @@ public void shutdown() {
483483
LOG.info("Shutting down embedded Ignite server");
484484
try {
485485
igniteStoreServer.close();
486-
igniteStoreServer = null;
487486
} catch (Exception e) {
488487
LOG.error("Error shutting down Ignite server", e);
488+
} finally {
489+
igniteStoreServer = null;
490+
}
491+
}
492+
}
493+
494+
/**
495+
* Close the pipe client, to be called after TikaGrpcServer has shut down.
496+
*/
497+
void postShutdown() {
498+
if (pipesClient != null) {
499+
LOG.info("Shutting down the pipes client");
500+
try {
501+
pipesClient.close();
502+
} catch (IOException e) {
503+
LOG.error("Error closing the pipes client", e);
504+
} finally {
505+
pipesClient = null;
489506
}
490507
}
491508
}

0 commit comments

Comments
 (0)