[jira] Created: (IO-147) Deletion of orphaned Softlinks does not work

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
Deletion of orphaned Softlinks does not work
--------------------------------------------

                 Key: IO-147
                 URL: https://issues.apache.org/jira/browse/IO-147
             Project: Commons IO
          Issue Type: Bug
    Affects Versions: 1.3.2
         Environment: Debian Linux JDK 1.5
            Reporter: Stefan Lischke
            Priority: Critical


If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.

This is caused by the "ugly" file.exists() call in forceDelete()

if (!file.exists()) {
         throw new FileNotFoundException("File does not exist: " + file);
}

if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.

Please discuss and change this.

thanx

Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)

    [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12552844 ]

Niall Pemberton commented on IO-147:
------------------------------------

Looking back thru the svn history this is the way it originally worked and the file.exists() check was added in r140382 [1] back in August 2003 (before IO 1.0 was released) - looking at the Bugzilla tickets 22075 (IO-62) and 22332 (IO-55) referenced in the log message there is no mention of this change - so it looks like it slipped in without explanation.

I guess the main reasoning is that it allows people using that method to distinguish between files which don't exist(FileNotFoundException) and other problems(IOException) when trying to delete. If we remove that check as you suggest then any application relying on a FileNotFoundException being thrown for non-existant files will break.

[1] http://svn.apache.org/viewvc?view=rev&revision=140382

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Priority: Critical
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

    [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553198 ]

Sebb commented on IO-147:
-------------------------

The Javadoc for forceDelete() fails to mention that it can throw  FileNotFoundException.
AFAICS there is no test for deleting a non-existent file.

A compromise solution would be to check if the file exists, and then try and delete it.
If the deletion fails, then either throw FileNotFoundException or IOException as appropriate.

Patch to follow.

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Priority: Critical
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated IO-147:
--------------------

    Attachment: FileUtils.patch

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Priority: Critical
>         Attachments: FileUtils.patch
>
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

    [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555475#action_12555475 ]

Mark Chaimungkalanont commented on IO-147:
------------------------------------------

Niall,

Any thoughts on this patch? Do you think it's something that would trigger off a quick 1.3.3 release? It's something that we're pretty keen on as well.

Cheers,

Mark C

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Priority: Critical
>         Attachments: FileUtils.patch
>
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

    [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555482#action_12555482 ]

Niall Pemberton commented on IO-147:
------------------------------------

Patch looks good to me - so I applied it - thanks Sebb:
    http://svn.apache.org/viewvc?view=rev&revision=608338

Regarding a release, we have enough changes already for a 1.4 release IMO. Don't know how quick that will be though.

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Priority: Critical
>         Attachments: FileUtils.patch
>
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (IO-147) Deletion of orphaned Softlinks does not work

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/IO-147?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved IO-147.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4
         Assignee: Niall Pemberton

> Deletion of orphaned Softlinks does not work
> --------------------------------------------
>
>                 Key: IO-147
>                 URL: https://issues.apache.org/jira/browse/IO-147
>             Project: Commons IO
>          Issue Type: Bug
>    Affects Versions: 1.3.2
>         Environment: Debian Linux JDK 1.5
>            Reporter: Stefan Lischke
>            Assignee: Niall Pemberton
>            Priority: Critical
>             Fix For: 1.4
>
>         Attachments: FileUtils.patch
>
>
> If there is an orphaned softlink a -> b, but b does not exists anymore than the softlink will not be removed. This happens when you call FileUtils.deleteDirectory() and when the linked target b is deleted earlier than the link.
> This is caused by the "ugly" file.exists() call in forceDelete()
> if (!file.exists()) {
>          throw new FileNotFoundException("File does not exist: " + file);
> }
> if this check is not done, everything works as expected. I think this test is not neccessery, cause file.delete will test this better.
> Please discuss and change this.
> thanx
> Stefan

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.