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
Created attachment 23295 [details] 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.
patch applied as svn revision 747004 Thanks!