HADOOP-9576. Changed NetUtils#wrapException to throw EOFException instead of wrapping it as IOException. Contributed by Steve Loughran

Conflicts:
	hadoop-common-project/hadoop-common/CHANGES.txt
This commit is contained in:
Jian He 2014-11-10 17:17:01 -08:00 committed by Arun C. Murthy
parent 9613a57e83
commit aa2f87caaf
2 changed files with 20 additions and 0 deletions

View File

@ -17,6 +17,7 @@
*/
package org.apache.hadoop.net;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -759,6 +760,13 @@ public static IOException wrapException(final String destHost,
+ " failed on socket timeout exception: " + exception
+ ";"
+ see("NoRouteToHost"));
} else if (exception instanceof EOFException) {
return wrapWithMessage(exception,
"End of File Exception between "
+ getHostDetailsAsString(destHost, destPort, localHost)
+ ": " + exception
+ ";"
+ see("EOFException"));
}
else {
return (IOException) new IOException("Failed on local exception: "

View File

@ -19,6 +19,7 @@
import static org.junit.Assert.*;
import java.io.EOFException;
import java.io.IOException;
import java.net.BindException;
import java.net.ConnectException;
@ -256,6 +257,17 @@ public void testWrapUnknownHostException() throws Throwable {
assertInException(wrapped, "/UnknownHost");
}
@Test
public void testWrapEOFException() throws Throwable {
IOException e = new EOFException("eof");
IOException wrapped = verifyExceptionClass(e, EOFException.class);
assertInException(wrapped, "eof");
assertWikified(wrapped);
assertInException(wrapped, "localhost");
assertRemoteDetailsIncluded(wrapped);
assertInException(wrapped, "/EOFException");
}
@Test
public void testGetConnectAddress() throws IOException {
NetUtils.addStaticResolution("host", "127.0.0.1");