Return-Path: X-Original-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-common-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1145BD2C2 for ; Fri, 21 Sep 2012 18:35:10 +0000 (UTC) Received: (qmail 3137 invoked by uid 500); 21 Sep 2012 18:35:09 -0000 Delivered-To: apmail-hadoop-common-issues-archive@hadoop.apache.org Received: (qmail 3101 invoked by uid 500); 21 Sep 2012 18:35:09 -0000 Mailing-List: contact common-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-issues@hadoop.apache.org Delivered-To: mailing list common-issues@hadoop.apache.org Received: (qmail 3056 invoked by uid 99); 21 Sep 2012 18:35:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Sep 2012 18:35:09 +0000 Date: Sat, 22 Sep 2012 05:35:09 +1100 (NCT) From: "Karthik Kambatla (JIRA)" To: common-issues@hadoop.apache.org Message-ID: <47268775.108724.1348252509202.JavaMail.jiratomcat@arcas> In-Reply-To: <765376368.106339.1348206488053.JavaMail.jiratomcat@arcas> Subject: [jira] [Updated] (HADOOP-8833) fs -text should make sure to call inputstream.seek(0) before using input stream MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HADOOP-8833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Karthik Kambatla updated HADOOP-8833: ------------------------------------- Status: Patch Available (was: Open) > fs -text should make sure to call inputstream.seek(0) before using input stream > ------------------------------------------------------------------------------- > > Key: HADOOP-8833 > URL: https://issues.apache.org/jira/browse/HADOOP-8833 > Project: Hadoop Common > Issue Type: Bug > Components: fs > Affects Versions: 2.0.2-alpha > Reporter: Harsh J > Assignee: Harsh J > Attachments: HADOOP-8833.patch, HADOOP-8833.patch > > > From Muddy Dixon on HADOOP-8449: > Hi > We found the changes in order of switch and guard block in > {code} > private InputStream forMagic(Path p, FileSystem srcFs) throws IOException > {code} > Because of this change, return value of > {code} > codec.createInputStream(i) > {code} > is changed if codec exists. > {code} > private InputStream forMagic(Path p, FileSystem srcFs) throws IOException { > FSDataInputStream i = srcFs.open(p); > // check codecs > CompressionCodecFactory cf = new CompressionCodecFactory(getConf()); > CompressionCodec codec = cf.getCodec(p); > if (codec != null) { > return codec.createInputStream(i); > } > switch(i.readShort()) { > // cases > } > {code} > New: > {code} > private InputStream forMagic(Path p, FileSystem srcFs) throws IOException { > FSDataInputStream i = srcFs.open(p); > switch(i.readShort()) { // <=== index (or pointer) processes!! > // cases > default: { > // Check the type of compression instead, depending on Codec class's > // own detection methods, based on the provided path. > CompressionCodecFactory cf = new CompressionCodecFactory(getConf()); > CompressionCodec codec = cf.getCodec(p); > if (codec != null) { > return codec.createInputStream(i); > } > break; > } > } > // File is non-compressed, or not a file container we know. > i.seek(0); > return i; > } > {code} > Fix is to use i.seek(0) before we use i anywhere. I missed that. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira