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 0589D200B7E for ; Tue, 6 Sep 2016 22:34:24 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 04A02160AA9; Tue, 6 Sep 2016 20:34:24 +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 4B046160ACB for ; Tue, 6 Sep 2016 22:34:23 +0200 (CEST) Received: (qmail 77443 invoked by uid 500); 6 Sep 2016 20:34:22 -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 77376 invoked by uid 99); 6 Sep 2016 20:34:22 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 20:34:22 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 360F32C1B75 for ; Tue, 6 Sep 2016 20:34:22 +0000 (UTC) Date: Tue, 6 Sep 2016 20:34:22 +0000 (UTC) From: "Chris Nauroth (JIRA)" To: common-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HADOOP-9819) FileSystem#rename is broken, deletes target when renaming link to itself MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 06 Sep 2016 20:34:24 -0000 [ https://issues.apache.org/jira/browse/HADOOP-9819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15468468#comment-15468468 ] Chris Nauroth commented on HADOOP-9819: --------------------------------------- bq. nobody really understands FileSystem.rename. That fact is documented in the spec... Yes, but are you interested in reviewing this patch despite our collective ignorance? :-) There is currently a risk that self-rename (same source and destination path) can accidentally delete the file with no copy remaining elsewhere, which is pretty obviously wrong. > FileSystem#rename is broken, deletes target when renaming link to itself > ------------------------------------------------------------------------ > > Key: HADOOP-9819 > URL: https://issues.apache.org/jira/browse/HADOOP-9819 > Project: Hadoop Common > Issue Type: Sub-task > Components: fs > Affects Versions: 3.0.0-alpha1 > Reporter: Arpit Agarwal > Assignee: Andras Bokor > Attachments: HADOOP-9819.01.patch, HADOOP-9819.02.patch, HADOOP-9819.03.patch > > > Uncovered while fixing TestSymlinkLocalFsFileSystem on Windows. > This block of code deletes the symlink, the correct behavior is to do nothing. > {code:java} > try { > dstStatus = getFileLinkStatus(dst); > } catch (IOException e) { > dstStatus = null; > } > if (dstStatus != null) { > if (srcStatus.isDirectory() != dstStatus.isDirectory()) { > throw new IOException("Source " + src + " Destination " + dst > + " both should be either file or directory"); > } > if (!overwrite) { > throw new FileAlreadyExistsException("rename destination " + dst > + " already exists."); > } > // Delete the destination that is a file or an empty directory > if (dstStatus.isDirectory()) { > FileStatus[] list = listStatus(dst); > if (list != null && list.length != 0) { > throw new IOException( > "rename cannot overwrite non empty destination directory " + dst); > } > } > delete(dst, false); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-issues-help@hadoop.apache.org