Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 35D1D17460 for ; Fri, 6 Nov 2015 06:21:04 +0000 (UTC) Received: (qmail 5396 invoked by uid 500); 6 Nov 2015 06:21:03 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 5308 invoked by uid 500); 6 Nov 2015 06:21:03 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 5291 invoked by uid 99); 6 Nov 2015 06:21:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Nov 2015 06:21:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5D089DFBC8; Fri, 6 Nov 2015 06:21:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cnauroth@apache.org To: common-commits@hadoop.apache.org Date: Fri, 06 Nov 2015 06:21:04 -0000 Message-Id: <894f11c5542747989f91ad63a421eaeb@git.apache.org> In-Reply-To: <363ea65820fb479fae09ac3b8f14101a@git.apache.org> References: <363ea65820fb479fae09ac3b8f14101a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] hadoop git commit: HDFS-9384. TestWebHdfsContentLength intermittently hangs and fails due to TCP conversation mismatch between client and server. Contributed by Chris Nauroth. HDFS-9384. TestWebHdfsContentLength intermittently hangs and fails due to TCP conversation mismatch between client and server. Contributed by Chris Nauroth. (cherry picked from commit 66c096731052fb187dc49f5bcaec8432c4b92d0c) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/75bcc8bc Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/75bcc8bc Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/75bcc8bc Branch: refs/heads/branch-2 Commit: 75bcc8bcd8199011420ff831c724f598229d6b9b Parents: 01ae307 Author: cnauroth Authored: Thu Nov 5 22:07:08 2015 -0800 Committer: cnauroth Committed: Thu Nov 5 22:07:34 2015 -0800 ---------------------------------------------------------------------- .../hdfs/web/TestWebHdfsContentLength.java | 23 +++++++++++++++++--- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/75bcc8bc/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java index ba99f7a..19f18b0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/web/TestWebHdfsContentLength.java @@ -38,8 +38,9 @@ import org.apache.hadoop.net.NetUtils; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; - +import org.junit.rules.Timeout; public class TestWebHdfsContentLength { private static ServerSocket listenSocket; @@ -58,6 +59,9 @@ public class TestWebHdfsContentLength { private static ExecutorService executor; + @Rule + public Timeout timeout = new Timeout(30000); + @BeforeClass public static void setup() throws IOException { listenSocket = new ServerSocket(); @@ -186,8 +190,21 @@ public class TestWebHdfsContentLength { client.getOutputStream().write(response.getBytes()); client.shutdownOutput(); byte[] buf = new byte[4*1024]; // much bigger than request - int n = client.getInputStream().read(buf); - return new String(buf, 0, n); + + // The second request can be sent with Transfer-Encoding: chunked. + // The Java HTTP client tends to split the headers and the chunked + // body into separate writes, so the first read likely only gets the + // headers. We must fully consume the input to prevent a hang on the + // client side. + StringBuilder sb = new StringBuilder(); + for (;;) { + int n = client.getInputStream().read(buf); + if (n <= 0) { + break; + } + sb.append(new String(buf, 0, n, "UTF-8")); + } + return sb.toString(); } finally { client.close(); } http://git-wip-us.apache.org/repos/asf/hadoop/blob/75bcc8bc/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index faaf69c..8a53dce 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1407,6 +1407,9 @@ Release 2.8.0 - UNRELEASED HDFS-9378. hadoop-hdfs-client tests do not write logs. (cnauroth) + HDFS-9384. TestWebHdfsContentLength intermittently hangs and fails due to + TCP conversation mismatch between client and server. (cnauroth) + Release 2.7.3 - UNRELEASED INCOMPATIBLE CHANGES