import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
}
private static String getHomePath() {
- return System.getProperty("user.home");
+ /*
+ * The environment variable LTTNG_HOME overrides HOME if
+ * defined.
+ */
+ String homePath = System.getenv("LTTNG_HOME");
+
+ if (homePath == null) {
+ homePath = System.getProperty("user.home");
+ }
+ return homePath;
}
/**
private static int getPortFromFile(String path) throws IOException {
int port;
BufferedReader br = null;
+ File file = new File(path);
try {
- br = new BufferedReader(new FileReader(path));
+ br = new BufferedReader(new FileReader(file));
String line = br.readLine();
port = Integer.parseInt(line, 10);
if (port < 0 || port > 65535) {
return null;
}
- this.inFromSessiond.read(payload, 0, payload.length);
+ int read = inFromSessiond.read(payload, 0, payload.length);
+ if (read != payload.length) {
+ throw new IOException("Unexpected number of bytes read in sessiond command payload");
+ }
return payload;
}