You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2009/02/20 17:02:08 UTC

DO NOT REPLY [Bug 46747] New: sync task crashes with NPE when trying to delete dead directory symlink

https://issues.apache.org/bugzilla/show_bug.cgi?id=46747

           Summary: sync task crashes with NPE when trying to delete dead
                    directory symlink
           Product: Ant
           Version: 1.7.1
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: skoppehel@intersoft.de


I've only tested this on Linux, I assume it is the same on all Unix-like
operating systems that support symlinks. Suppose you have in a directory a
subdirectory and a symbolic link to it. Then you try, via ant, to sync another
directory to it that contains neither. The sync task will try to delete both,
and will fail.

To set up a test case, do:

    mkdir t s t/n
    ln -s n t/m

and then execute the following ant target:

    <target name="synchro">
        <sync todir="t">
            <fileset dir="s">
                <include name="**/*" />
            </fileset>
        </sync>
    </target>

What will happen is this:

Buildfile: build.xml

synchro:

BUILD FAILED
java.lang.NullPointerException
        at org.apache.tools.ant.taskdefs.Sync.removeOrphanFiles(Sync.java:218)
        at org.apache.tools.ant.taskdefs.Sync.execute(Sync.java:118)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Total time: 0 seconds

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46747] sync task crashes with NPE when trying to delete dead directory symlink

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46747





--- Comment #1 from skoppehel@intersoft.de  2009-02-22 05:36:56 PST ---
Created an attachment (id=23295)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=23295)
Patch to test for null

The attached patch makes the NPE go away by testing f.list() for null before
looking at length. Whether or not the fact that a non-listable file appears at
this point is indicative of a deeper bug somewhere else, I cannot say. The test
case I described now works as expected, the dead link gets deleted.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

DO NOT REPLY [Bug 46747] sync task crashes with NPE when trying to delete dead directory symlink

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=46747


Stefan Bodewig <bo...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |1.8.0




--- Comment #2 from Stefan Bodewig <bo...@apache.org>  2009-02-23 05:14:44 PST ---
patch applied as svn revision 747004 ( https://svn.apache.org/viewcvs.cgi?view=rev&rev=747004 )

Thanks!

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.