HADOOP-15512. Clean up Shell from JDK7 workarounds.
Contributed by Zsolt Venczel.
This commit is contained in:
parent
58bc34f1e3
commit
f494f0b896
@ -22,7 +22,6 @@
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InterruptedIOException;
|
import java.io.InterruptedIOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -1018,17 +1017,7 @@ public void run() {
|
|||||||
}
|
}
|
||||||
// close the input stream
|
// close the input stream
|
||||||
try {
|
try {
|
||||||
// JDK 7 tries to automatically drain the input streams for us
|
inReader.close();
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOG.warn("Error while closing the input stream", ioe);
|
LOG.warn("Error while closing the input stream", ioe);
|
||||||
}
|
}
|
||||||
@ -1037,10 +1026,7 @@ public void run() {
|
|||||||
joinThread(errThread);
|
joinThread(errThread);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InputStream stderr = process.getErrorStream();
|
errReader.close();
|
||||||
synchronized (stderr) {
|
|
||||||
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
Block a user