HDFS-3829. TestHftpURLTimeouts fails intermittently with JDK7 (Trevor Robinson via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1394609 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Graves 2012-10-05 15:51:10 +00:00
parent dfb8369c29
commit d35169d9ba
2 changed files with 32 additions and 21 deletions

View File

@ -1677,6 +1677,9 @@ Release 0.23.5 - UNRELEASED
BUG FIXES BUG FIXES
HDFS-3829. TestHftpURLTimeouts fails intermittently with JDK7 (Trevor
Robinson via tgraves)
Release 0.23.4 - UNRELEASED Release 0.23.4 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -53,19 +53,23 @@ public void testHftpSocketTimeout() throws Exception {
boolean timedout = false; boolean timedout = false;
HftpFileSystem fs = (HftpFileSystem)FileSystem.get(uri, conf); HftpFileSystem fs = (HftpFileSystem)FileSystem.get(uri, conf);
HttpURLConnection conn = fs.openConnection("/", "");
timedout = false;
try { try {
// this will consume the only slot in the backlog HttpURLConnection conn = fs.openConnection("/", "");
conn.getInputStream(); timedout = false;
} catch (SocketTimeoutException ste) { try {
timedout = true; // this will consume the only slot in the backlog
assertEquals("Read timed out", ste.getMessage()); conn.getInputStream();
} catch (SocketTimeoutException ste) {
timedout = true;
assertEquals("Read timed out", ste.getMessage());
} finally {
if (conn != null) conn.disconnect();
}
assertTrue("read timedout", timedout);
assertTrue("connect timedout", checkConnectTimeout(fs, false));
} finally { } finally {
if (conn != null) conn.disconnect(); fs.close();
} }
assertTrue("read timedout", timedout);
assertTrue("connect timedout", checkConnectTimeout(fs, false));
} }
@Test @Test
@ -79,20 +83,24 @@ public void testHsftpSocketTimeout() throws Exception {
boolean timedout = false; boolean timedout = false;
HsftpFileSystem fs = (HsftpFileSystem)FileSystem.get(uri, conf); HsftpFileSystem fs = (HsftpFileSystem)FileSystem.get(uri, conf);
HttpURLConnection conn = null;
timedout = false;
try { try {
// this will consume the only slot in the backlog HttpURLConnection conn = null;
conn = fs.openConnection("/", ""); timedout = false;
} catch (SocketTimeoutException ste) { try {
// SSL expects a negotiation, so it will timeout on read, unlike hftp // this will consume the only slot in the backlog
timedout = true; conn = fs.openConnection("/", "");
assertEquals("Read timed out", ste.getMessage()); } catch (SocketTimeoutException ste) {
// SSL expects a negotiation, so it will timeout on read, unlike hftp
timedout = true;
assertEquals("Read timed out", ste.getMessage());
} finally {
if (conn != null) conn.disconnect();
}
assertTrue("ssl read connect timedout", timedout);
assertTrue("connect timedout", checkConnectTimeout(fs, true));
} finally { } finally {
if (conn != null) conn.disconnect(); fs.close();
} }
assertTrue("ssl read connect timedout", timedout);
assertTrue("connect timedout", checkConnectTimeout(fs, true));
} }
private boolean checkConnectTimeout(HftpFileSystem fs, boolean ignoreReadTimeout) private boolean checkConnectTimeout(HftpFileSystem fs, boolean ignoreReadTimeout)