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 2010/04/16 18:43:10 UTC

DO NOT REPLY [Bug 49137] New: Ant Symlink task generates Null Pointer exception with stack trace when trying to delete symlink

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

           Summary: Ant Symlink task generates Null Pointer exception with
                    stack trace when trying to delete symlink
           Product: Ant
           Version: 1.8.0
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
        AssignedTo: notifications@ant.apache.org
        ReportedBy: brad.macphee@newpace.ca


As you can see below, I'm using the symlink task to delete a symlink.  The
build.xml has been simplified to the very minimum, so my use case isn't really
obvious here, but what I provided still reproduces the problem.  Find the stack
trace at the end of this description.

Here are the details on the environment (java version, build xml, and relevant
directory layout:

masheen# java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode)


masheen# pwd
/home/bmacphee/project1

masheen# cat build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="project1" default="build" basedir=".">
    <target name="build">
        <symlink action="delete" link="Templates"/>
    </target>
</project>


masheen# ls -go
total 9
lrwxrwxrwx   1      12 Apr 16 09:47 Templates -> ../Templates
-rw-r--r--   1     199 Apr 16 12:18 build.xml

masheen# ls -go ../
total 9
drwxr-xr-x   2       2 Apr 16 09:47 Templates
drwxr-xr-x   2       4 Apr 16 12:19 project1



masheen# ant
Buildfile: /home/bmacphee/project1/build.xml

build:
  [symlink] Removing symlink: Templates

BUILD FAILED
/home/bmacphee/project1/build.xml:4: java.lang.NullPointerException
        at
org.apache.tools.ant.util.SymbolicLinkUtils.isSymbolicLink(SymbolicLinkUtils.java:107)
        at
org.apache.tools.ant.util.SymbolicLinkUtils.isSymbolicLink(SymbolicLinkUtils.java:73)
        at
org.apache.tools.ant.util.SymbolicLinkUtils.deleteSymbolicLink(SymbolicLinkUtils.java:223)
        at
org.apache.tools.ant.taskdefs.optional.unix.Symlink.delete(Symlink.java:187)
        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:77)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:390)
        at org.apache.tools.ant.Target.performTasks(Target.java:411)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
        at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
        at org.apache.tools.ant.Main.runBuild(Main.java:801)
        at org.apache.tools.ant.Main.startAnt(Main.java:218)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 1 second

-- 
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 49137] Ant Symlink task generates Null Pointer exception with stack trace when trying to delete symlink

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

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

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

--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2010-04-16 16:05:09 EDT ---
Apparently, if you create a File instance using new File("name") and ./name
is a symbolic link then this file's getParent() returns null.

If you create new File(new File("."), "name") you get the current directory as
parent.  Learn something new every day.

As a workaround for your case, use link="./Templates" and the delete succeeds.

Fixed in svn revision 935064

Realized that link is not resolved against basedir but against the current
working directory and didn't dare to change that for backwards compatibility -
will document that.

Many thanks for the testcase.

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