From common-issues-return-151729-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Fri Apr 27 12:09:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C9B7518067A for ; Fri, 27 Apr 2018 12:09:04 +0200 (CEST) Received: (qmail 16867 invoked by uid 500); 27 Apr 2018 10:09:03 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 16818 invoked by uid 99); 27 Apr 2018 10:09:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2018 10:09:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id F26A2C015D for ; Fri, 27 Apr 2018 10:09:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 2ULcP_qW1mWI for ; Fri, 27 Apr 2018 10:09:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id B519F5FB9D for ; Fri, 27 Apr 2018 10:09:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1AA0CE1281 for ; Fri, 27 Apr 2018 10:09:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7BCF52425C for ; Fri, 27 Apr 2018 10:09:00 +0000 (UTC) Date: Fri, 27 Apr 2018 10:09:00 +0000 (UTC) From: "Steve Loughran (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HADOOP-15415) copyBytes hangs when the configuration file is corrupted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-15415?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:all-tabpanel ] Steve Loughran updated HADOOP-15415: ------------------------------------ Affects Version/s: 3.1.0 > copyBytes hangs when the configuration file is corrupted > -------------------------------------------------------- > > Key: HADOOP-15415 > URL: https://issues.apache.org/jira/browse/HADOOP-15415 > Project: Hadoop Common > Issue Type: Bug > Components: common > Affects Versions: 0.23.0, 3.1.0 > Reporter: John Doe > Priority: Major > > The third parameter,=C2=A0 buffSize, is read from the configuration files= or user-specified. > When the configuration file is corrupted or the user configures with a wr= ong value, i.e., 0, the bytesRead will always be 0, making the while loop's= condition always true, hanging IOUtils.copyBytes() endlessly. > Here is the snippet=C2=A0of the code. There are four copyBytes in the fol= lowing code. The 3rd and 4th copyBytes calls the 1st one. The 1st one calls= the 2nd one. Hang happens in the while loop of the second copyBytes functi= on. > =C2=A0 > {code:java} > //1st copyBytes > public static void copyBytes(InputStream in, OutputStream out, int buff= Size, boolean close)=20 > throws IOException { > try { > copyBytes(in, out, buffSize); > if(close) { > out.close(); > out =3D null; > in.close(); > in =3D null; > } > } finally { > if(close) { > closeStream(out); > closeStream(in); > } > } > } > =20 > //2nd copyBytes > public static void copyBytes(InputStream in, OutputStream out, int buff= Size)=20 > throws IOException { > PrintStream ps =3D out instanceof PrintStream ? (PrintStream)out : nu= ll; > byte buf[] =3D new byte[buffSize]; > int bytesRead =3D in.read(buf); > while (bytesRead >=3D 0) { > out.write(buf, 0, bytesRead); > if ((ps !=3D null) && ps.checkError()) { > throw new IOException("Unable to write to output stream."); > } > bytesRead =3D in.read(buf); > } > } > //3rd copyBytes > public static void copyBytes(InputStream in, OutputStream out, Configur= ation conf) > throws IOException { > copyBytes(in, out, conf.getInt("io.file.buffer.size", 4096), true); > } > =20 > //4th copyBytes > public static void copyBytes(InputStream in, OutputStream out, Configur= ation conf, boolean close) > throws IOException { > copyBytes(in, out, conf.getInt("io.file.buffer.size", 4096), close); > } > {code} > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org