Don't set 'user.dir' if the working directory could not be set.
This commit is contained in:
@@ -32,27 +32,26 @@ public class DefaultProcess implements Process {
|
||||
|
||||
public File getWorkingDirectory() throws NativeException {
|
||||
FunctionResult result = new FunctionResult();
|
||||
String dir;
|
||||
synchronized (workingDirectoryLock) {
|
||||
dir = PosixProcessFunctions.getWorkingDirectory(result);
|
||||
}
|
||||
String dir = PosixProcessFunctions.getWorkingDirectory(result);
|
||||
if (result.isFailed()) {
|
||||
throw new NativeException(String.format("Could not get process working directory: %s",
|
||||
result.getMessage()));
|
||||
}
|
||||
return new File(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWorkingDirectory(File directory) throws NativeException {
|
||||
FunctionResult result = new FunctionResult();
|
||||
synchronized (workingDirectoryLock) {
|
||||
PosixProcessFunctions.setWorkingDirectory(directory.getAbsolutePath(), result);
|
||||
System.setProperty("user.dir", directory.getAbsolutePath());
|
||||
}
|
||||
if (result.isFailed()) {
|
||||
throw new NativeException(String.format("Could not set process working directory: %s",
|
||||
result.getMessage()));
|
||||
}
|
||||
System.setProperty("user.dir", directory.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
public String getEnvironmentVariable(String name) throws NativeException {
|
||||
|
||||
Reference in New Issue
Block a user