Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5
-
None
-
None
-
Operating System: Linux
Platform: All
-
33924
Description
The AnakiaTask has the feature to use a custom context object. This is tested in
the AnakiaTestCase. However, when running this test (and the AnakiaTask) under
Maven, it fails with a NullPointerException. The reason is that maven uses a
different sequence to initialize the AnakiaTask and Context objects and set
their properties. When running under ant, the setFile() method in the Context
object is called after setBaseDir() in the AnakiaTask, which allows setFile() to
resolve the baseDir member. When running under maven, setBasedir() is called
after the Context object has been initialized thus using a null baseDir element
when creating the contextFile element in Context.
When using an element outside the current working directory, this leads to
subContext.getContextDocument() returning null in line 378, thus resulting in a
NullPointerException.
The attached patch adds checks for this condition and throws a BuildExeption. It
also defers the creation of the contextDoc member of the context until it is
actually referenced.