You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2022/04/06 14:56:49 UTC

[tika] branch main updated: TIKA-3715 -- push forking processes' env variables into forked process.

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

tallison 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 ad29e809d TIKA-3715 -- push forking processes' env variables into forked process.
     new 031c9d16c Merge remote-tracking branch 'origin/main' into main
ad29e809d is described below

commit ad29e809d4263227813a44bb6e56b046b41af4e2
Author: tallison <ta...@apache.org>
AuthorDate: Wed Apr 6 10:56:36 2022 -0400

    TIKA-3715 -- push forking processes' env variables into forked process.
---
 CHANGES.txt                                                       | 3 +++
 .../main/java/org/apache/tika/server/core/TikaServerWatchDog.java | 8 +++-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 4bd57be0f..1a4b552f7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -18,6 +18,9 @@ Release 2.4.0 - ???
 
    * Add a fetcher and emitter for Azure blob storage (TIKA-3707).
 
+   * tika-server now clones forking process' environment variables
+     into forked process (TIKA-3715).
+
    * Add an optional /eval endpoint for tika-eval profile or compare
      capabilities in tika-server (TIKA-3689).
 
diff --git a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerWatchDog.java b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerWatchDog.java
index b23c6bab3..650a7e2c0 100644
--- a/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerWatchDog.java
+++ b/tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerWatchDog.java
@@ -398,14 +398,12 @@ public class TikaServerWatchDog implements Callable<WatchDogResult> {
             argList.add(Integer.toString(numRestarts));
             LOG.debug("forked process commandline: " + argList.toString());
             builder.command(argList);
+            //copy forking processes' env variables
+            builder.environment().putAll(System.getenv());
+            //now overwrite with the specific server id
             //this is mostly for log4j 2.x so that different processes
             //can log to different log files via {env:tika.server.id}
             builder.environment().put(TIKA_SERVER_ID_ENV, id);
-            //pass through from forking process
-            String tikaConfigEnv = System.getenv("TIKA_CONFIG");
-            if (tikaConfigEnv != null) {
-                builder.environment().put("TIKA_CONFIG", tikaConfigEnv);
-            }
             Process process = builder.start();
             PROCESSES.add(process);
             //redirect stdout to parent stderr to avoid error msgs