• Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
    • Environment:

      Operating System: other
      Platform: Other


      In an attempt to reuse a digester to parse multiple
      files, I found that I was always getting the contents
      of the first file I parsed.

      It turns out the that what happens, is that
      Digester.endDocument() handles the end-of-document event.
      At the end of the method, Digester.clear() is called.
      You'll notice that clear() actually clears all the rules!
      So the next time you parse, no rules are fired, and the
      parser returns normally (not signalling any exceptions
      which would be caught in the test-case). The private
      field 'root' remains unchanged from the original parse,
      and the originally parsed (root) object is returned.

      It was a simple fix...patch is included for both and Here are some notes
      on the patch, since functionality changed slightly.

      The method 'clear()' has been changed to not clear the
      rules. This keeps with the stated documentation that clear()
      which suggests that only clears the object stack. Additionally,
      I extended clear() to set root to null. This seems to make
      sense from the point of view of a user of the Digester API.
      If I want to "clear" my digester, I also want the root to be
      set to null, this frees a reference to my root object to allow
      it to (possibly) be garbage collected.

      I've refactored the functionality of the 'public clear()'
      to a 'private clear(boolean)' method which allows the caller
      to determine whether or not root should be cleared. This
      way, endDocument() can call clear(false), and make sure that
      root is not set to null.

      Lastly, I've updated RuleTestCase to fail if the instances
      returned for two subsequent parses reference the same object.


        Gidado-Yisa Immanuel created issue -
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 4073 12340158
        Henri Yandell made changes -
        Key COM-7 DIGESTER-19
        Project Commons [ 12310458 ] Commons Digester [ 12310471 ]
        Assignee Craig McClanahan [ ]
        Component/s Digester [ 12311111 ]
        Affects Version/s Nightly Builds [ 12311648 ]
        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311810 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]


          • Assignee:
            Gidado-Yisa Immanuel
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: