Bug 41284 - dependset throws NullPointerException
Summary: dependset throws NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.7.0
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: 1.7.1
Assignee: Ant Notifications List
URL:
Keywords:
: 44368 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-01-03 16:12 UTC by Joseph A Thompson
Modified: 2008-02-22 12:18 UTC (History)
1 user (show)



Attachments
Contains test files and output log. (2.07 KB, application/octet-stream)
2007-01-03 16:14 UTC, Joseph A Thompson
Details
Output log and fragment of correctly sorted list of java files (1.65 KB, application/octet-stream)
2007-01-29 14:10 UTC, Joseph A Thompson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph A Thompson 2007-01-03 16:12:57 UTC
dependset throws a NullPointerException.  The failure appears to occur at the
point where DependSet.uptodate() sorts the list of sources, and gets the first
element of the list. (line 233 in DependSet.java). 
This works correctly in Version 1.6.5.

Stack trace from log:
--- Nested Exception ---
java.lang.NullPointerException
	at
org.apache.tools.ant.types.resources.Sort$SortedBag$MutableInt.access$100(Sort.java:44)
	at
org.apache.tools.ant.types.resources.Sort$SortedBag$MyIterator.next(Sort.java:60)
	at org.apache.tools.ant.types.resources.FailFast.next(FailFast.java:115)
	at org.apache.tools.ant.taskdefs.DependSet.uptodate(DependSet.java:233)
	at org.apache.tools.ant.taskdefs.DependSet.execute(DependSet.java:202)
	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:585)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
	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:1329)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
	at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
	at org.apache.tools.ant.Main.runBuild(Main.java:698)
	at org.apache.tools.ant.Main.startAnt(Main.java:199)
	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Comment 1 Joseph A Thompson 2007-01-03 16:14:34 UTC
Created attachment 19350 [details]
Contains test files and output log.
Comment 2 Joseph A Thompson 2007-01-03 16:17:02 UTC
Note that the problem only occurs when the target file exists.
Comment 3 Matt Benson 2007-01-04 09:02:33 UTC
Hi Joseph,
  I have DLd your attachment but it does not contain a complete self-hosting
environment.  I tried to compensate for that fact but have not been able to
reproduce the NPE.  A more complete build would be helpful.  It might also be
helpful to know what Java version you are using.

Thanks,
Matt
Comment 4 Joseph A Thompson 2007-01-04 09:10:43 UTC
The source (src) directory for the sandbox where this bug occurred contains 5448
.java files and 127 .jsp files in numerous directories. Can't really share all
that (size is prohibitive, and the source is proprietary). 

java -version returns
java version "1.5.0_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)
Comment 5 Matt Benson 2007-01-04 10:29:22 UTC
(In reply to comment #4)
> The source (src) directory for the sandbox where this bug occurred contains 5448
> .java files and 127 .jsp files in numerous directories. Can't really share all
> that (size is prohibitive, and the source is proprietary). 
> 
> java -version returns
> java version "1.5.0_09"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
> Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

Based on size alone, I certainly wouldn't want you to share all that.  At the
same time, I can slap a few files into various directories under src/ and I
don't get the NPE.  So there must be something unique to your directory
structure that triggers the error.  The most important component of a bugreport
is as small as possible a self-contained example that triggers the problem. 
You've got to help us help you...  :|
Comment 6 J.M. (Martijn) Kruithof 2007-01-27 14:41:37 UTC
In an artificial environment where I have only tested the SortedBag I am able to
reproduce this error, that is the same error occurs in case the object in the
TreeMap is changed, so that its position in the map changes. Because of this the
key retrieved using the key iterator cannot be found anymore in the map (because
its position according to its ordering has changed.)

In this case it probably implies that the Newest File isn't the Newest anymore...
Comment 7 J.M. (Martijn) Kruithof 2007-01-27 15:43:14 UTC
If this was the cause it is fixed in head now, please verify.
Comment 8 Joseph A Thompson 2007-01-29 14:10:21 UTC
Created attachment 19478 [details]
Output log and fragment of correctly sorted list of java files

I have tested the fix (nightly build apache-ant-20070128). The NPE is gone, but
the sort is not working correctly. I tested this in both in our actual
development sandbox and in the ant directory. If you drop the test files I
originally attached into the ant directory and run ant -f problem.xml, the
first time thru it should create the BuildID.properties file (because it
doesn't exist). If you then touch an arbitrary .java source file and re-run, it
should create a new BuildID.properties with a new date-time stamp. It doesn't.
I've attached a zip with the log from such a run on my machine and a fragment
of an externally-sorted list of all the .java files, and this clearly shows
that the sort in DependSet is not properly ordering the files.
Comment 9 J.M. (Martijn) Kruithof 2007-01-30 12:09:30 UTC
The nightly builds do not seem to pick up the recent changes, (also this bug is
not fixed in the nightly build of the 29th) these builds still contain the wrong
classes. The behaviour you observed is described in another report.

(Bugzilla report 41411)
Comment 10 J.M. (Martijn) Kruithof 2007-01-30 12:20:08 UTC
I have put a manual build (on windows, unix permission will be wrong!) on:

http://people.apache.org/~jkf/apache-ant-20070130-bin.tgz
Comment 11 Joseph A Thompson 2007-01-30 13:29:33 UTC
The manual build supplied (apache-ant-20070130-bin.tgz) does appear to fix the
problem. 

Thanks, guys!

Joe T.
Comment 12 J.M. (Martijn) Kruithof 2008-02-08 10:33:19 UTC
*** Bug 44368 has been marked as a duplicate of this bug. ***