Bug 48715 - FileMatch throws NPE when file2 is smaller than file1 doing text comparison
Summary: FileMatch throws NPE when file2 is smaller than file1 doing text comparison
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.0
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: 1.8.1
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-09 13:28 UTC by Rama Pulavarthi
Modified: 2010-02-09 21:38 UTC (History)
0 users



Attachments
Testcase (887 bytes, application/x-sdlc)
2010-02-09 13:29 UTC, Rama Pulavarthi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rama Pulavarthi 2010-02-09 13:28:24 UTC
Usage:
<condition property="files_equal">
    <filesmatch file1="${file1}" file2="${file2}" textfile="true"/>
</condition>

Testcase is attached.

Here is the stack trace
java.lang.NullPointerException
	at java.lang.String.compareTo(String.java:998)
	at org.apache.tools.ant.util.ResourceUtils.textCompare(ResourceUtils.java:669)
	at org.apache.tools.ant.util.ResourceUtils.compareContent(ResourceUtils.java:592)
	at org.apache.tools.ant.util.ResourceUtils.contentEquals(ResourceUtils.java:556)
	at org.apache.tools.ant.util.FileUtils.contentEquals(FileUtils.java:969)
	at org.apache.tools.ant.taskdefs.condition.FilesMatch.eval(FilesMatch.java:92)
	at org.apache.tools.ant.taskdefs.ConditionTask.execute(ConditionTask.java:120)
	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:592)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
	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:592)
	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: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: 0 seconds
Comment 1 Rama Pulavarthi 2010-02-09 13:29:15 UTC
Created attachment 24957 [details]
Testcase
Comment 2 Stefan Bodewig 2010-02-09 21:38:18 UTC
thanks!

fixed in svn revision 908356

I think a workaround is to use textfile="false".