Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A1CE3200C40 for ; Thu, 9 Mar 2017 03:01:42 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A0795160B8B; Thu, 9 Mar 2017 02:01:42 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id EDEF5160B83 for ; Thu, 9 Mar 2017 03:01:41 +0100 (CET) Received: (qmail 17319 invoked by uid 500); 9 Mar 2017 02:01:41 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 17295 invoked by uid 99); 9 Mar 2017 02:01:41 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Mar 2017 02:01:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 80705C3B57 for ; Thu, 9 Mar 2017 02:01:40 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.151 X-Spam-Level: * X-Spam-Status: No, score=1.151 tagged_above=-999 required=6.31 tests=[KAM_NUMSUBJECT=0.5, RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id FmmgrPWx3cfw for ; Thu, 9 Mar 2017 02:01:39 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 4A15F5F1F4 for ; Thu, 9 Mar 2017 02:01:39 +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 79D0FE0593 for ; Thu, 9 Mar 2017 02:01:38 +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 2C980243AE for ; Thu, 9 Mar 2017 02:01:38 +0000 (UTC) Date: Thu, 9 Mar 2017 02:01:38 +0000 (UTC) From: "SammiChen (JIRA)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HDFS-9705) Refine the behaviour of getFileChecksum when length = 0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 09 Mar 2017 02:01:42 -0000 [ https://issues.apache.org/jira/browse/HDFS-9705?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] SammiChen updated HDFS-9705: ---------------------------- Attachment: (was: HDFS-9705-v7.patch) > Refine the behaviour of getFileChecksum when length = 0 > ------------------------------------------------------- > > Key: HDFS-9705 > URL: https://issues.apache.org/jira/browse/HDFS-9705 > Project: Hadoop HDFS > Issue Type: Improvement > Reporter: Kai Zheng > Assignee: Kai Zheng > Priority: Minor > Attachments: HDFS-9705-v1.patch, HDFS-9705-v2.patch, HDFS-9705-v3.patch, HDFS-9705-v4.patch, HDFS-9705-v5.patch, HDFS-9705-v6.patch, HDFS-9705-v7.patch > > > {{FileSystem#getFileChecksum}} may accept {{length}} parameter and 0 is a valid value. Currently it will return {{null}} when length is 0, in the following code block: > {code} > //compute file MD5 > final MD5Hash fileMD5 = MD5Hash.digest(md5out.getData()); > switch (crcType) { > case CRC32: > return new MD5MD5CRC32GzipFileChecksum(bytesPerCRC, > crcPerBlock, fileMD5); > case CRC32C: > return new MD5MD5CRC32CastagnoliFileChecksum(bytesPerCRC, > crcPerBlock, fileMD5); > default: > // If there is no block allocated for the file, > // return one with the magic entry that matches what previous > // hdfs versions return. > if (locatedblocks.size() == 0) { > return new MD5MD5CRC32GzipFileChecksum(0, 0, fileMD5); > } > // we should never get here since the validity was checked > // when getCrcType() was called above. > return null; > } > {code} > The comment says "we should never get here since the validity was checked" but it does. As we're using the MD5-MD5-X approach, and {{EMPTY--CONTENT}} actually is a valid case in which the MD5 value is {{d41d8cd98f00b204e9800998ecf8427e}}, so suggest we return a reasonable value other than null. At least some useful information in the returned value can be seen, like values from block checksum header. -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org