HADOOP-10146. Workaround JDK7 Process fd close bug (daryn)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1558883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3928de29fc
commit
5421725907
|
@ -526,6 +526,8 @@ Release 2.4.0 - UNRELEASED
|
||||||
HADOOP-10236. Fix typo in o.a.h.ipc.Client#checkResponse. (Akira Ajisaka
|
HADOOP-10236. Fix typo in o.a.h.ipc.Client#checkResponse. (Akira Ajisaka
|
||||||
via suresh)
|
via suresh)
|
||||||
|
|
||||||
|
HADOOP-10146. Workaround JDK7 Process fd close bug (daryn)
|
||||||
|
|
||||||
Release 2.3.0 - UNRELEASED
|
Release 2.3.0 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
|
@ -511,7 +512,17 @@ abstract public class Shell {
|
||||||
}
|
}
|
||||||
// close the input stream
|
// close the input stream
|
||||||
try {
|
try {
|
||||||
|
// JDK 7 tries to automatically drain the input streams for us
|
||||||
|
// when the process exits, but since close is not synchronized,
|
||||||
|
// it creates a race if we close the stream first and the same
|
||||||
|
// fd is recycled. the stream draining thread will attempt to
|
||||||
|
// drain that fd!! it may block, OOM, or cause bizarre behavior
|
||||||
|
// see: https://bugs.openjdk.java.net/browse/JDK-8024521
|
||||||
|
// issue is fixed in build 7u60
|
||||||
|
InputStream stdout = process.getInputStream();
|
||||||
|
synchronized (stdout) {
|
||||||
inReader.close();
|
inReader.close();
|
||||||
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOG.warn("Error while closing the input stream", ioe);
|
LOG.warn("Error while closing the input stream", ioe);
|
||||||
}
|
}
|
||||||
|
@ -524,7 +535,10 @@ abstract public class Shell {
|
||||||
LOG.warn("Interrupted while joining errThread");
|
LOG.warn("Interrupted while joining errThread");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
InputStream stderr = process.getErrorStream();
|
||||||
|
synchronized (stderr) {
|
||||||
errReader.close();
|
errReader.close();
|
||||||
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOG.warn("Error while closing the error stream", ioe);
|
LOG.warn("Error while closing the error stream", ioe);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue