Add support for LTTNG_UST_HOME
[lttng-ust.git] / src / lib / lttng-ust-java-agent / java / lttng-ust-agent-common / org / lttng / ust / agent / client / LttngTcpSessiondClient.java
index cb84087af6a42fc81aa434dd7ec1018098c3e567..2c44a0df98f5455c3eb15cc7c2f5a3bc05e85f1a 100644 (file)
@@ -197,15 +197,29 @@ public class LttngTcpSessiondClient implements Runnable {
 
        private static String getHomePath() {
                /*
+                * The environment variable LTTNG_UST_HOME overrides LTTNG_HOME
+                * if present.
                 * The environment variable LTTNG_HOME overrides HOME if
                 * defined.
                 */
-               String homePath = System.getenv("LTTNG_HOME");
+               String lttngUstHomePath = System.getenv("LTTNG_UST_HOME");
+               String lttngHomePath = System.getenv("LTTNG_HOME");
+
+               if (lttngUstHomePath != null) {
+                       /*
+                        * LTTNG_UST_HOME has priority over LTTNG_HOME and user
+                        * home directory.
+                        */
+                       return lttngUstHomePath;
+               }
 
-               if (homePath == null) {
-                       homePath = System.getProperty("user.home");
+               if (lttngHomePath != null) {
+                       /* LTTNG_HOME has priority over user home directory. */
+                       return lttngHomePath;
                }
-               return homePath;
+
+               /* Default to the user home directory. */
+               return System.getProperty("user.home");
        }
 
        /**
This page took 0.024656 seconds and 4 git commands to generate.