Bug 52754 - XMLCatalog.ExternalResolver handles CWD differently than InternalResolver
Summary: XMLCatalog.ExternalResolver handles CWD differently than InternalResolver
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.8.3
Hardware: PC Linux
: P2 minor (vote)
Target Milestone: 1.9.0
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-23 20:40 UTC by Jesse Glick
Modified: 2012-02-23 20:43 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2012-02-23 20:40:22 UTC
cd /tmp && ant -f .../build.xml -Dtestcase='org.apache.tools.ant.types.XMLCatalogTest' test

fails:

junit.framework.AssertionFailedError: Empty catalog should return input with a system ID like file:/.../i/dont/exist.dtd but was tmp/i/dont/exist.dtd
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.assertTrue(Assert.java:20)
	at org.apache.tools.ant.types.XMLCatalogTest.testEmptyCatalog(XMLCatalogTest.java:94)

junit.framework.AssertionFailedError: Nonexistent Catalog entry return input with a system ID like file:/tmp/file:/.../i/dont/exist.dtd but was tmp/i/dont/exist.dtd
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.assertTrue(Assert.java:20)
	at org.apache.tools.ant.types.XMLCatalogTest.testNonExistentEntry(XMLCatalogTest.java:139)

In XMLCatalog.resolve, getCatalogResolver() is an ExternalCatalog and resolving  a relative path with a null base is done against the JVM's CWD rather than the project's basedir.

If you force the resolver to be an InternalResolver, the test passes. Seems that the external resolver when encountering an href with no matching entry fails to use the basedir as a URL base.
Comment 1 Jesse Glick 2012-02-23 20:43:07 UTC
Committed revision 1292945.