Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-367

Anakia throws NullPointerException if run under Maven with Custom Contexts

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5
    • None
    • Anakia
    • 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.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            henning Henning Schmiedehausen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment