castor
  1. castor
  2. CASTOR-2012

hashCode() and equals() infinitely recurse with cyclid IDREFs

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.2
    • Component/s: XML code generator
    • Labels:
      None
    • Environment:
      WIndows XP SP2/Linux/OSX j1.4,1.5,1.6
    • Testcase included:
      yes
    • Number of attachments :
      4

      Description

      Elements with elements or attributes of type IDREF or IDREFs that for a particular instance resolve to any parent element will result in an StackOverflowError when either the hashCode or equals methods are called.

      1. bug2012.zip
        4 kB
        Jim Procter
      2. CycleBreaker.java
        3 kB
        Jim Procter
      3. patch-C2012-20070804.txt
        10 kB
        Ralf Joachim
      4. SourceFactorybug2012alltests.patch
        5 kB
        Jim Procter

        Activity

        Hide
        Jim Procter added a comment -

        test case exhibiting cyclic IDREF in hashCode and equals methods

        Show
        Jim Procter added a comment - test case exhibiting cyclic IDREF in hashCode and equals methods
        Hide
        Jim Procter added a comment -

        patch for SourceFactory version from SVN tagged with castor-1.1

        Show
        Jim Procter added a comment - patch for SourceFactory version from SVN tagged with castor-1.1
        Hide
        Jim Procter added a comment -

        org.castor.util.CycleBreaker class implementing the thread safe cycle detection methods used in the SourceGenerator patch.

        Show
        Jim Procter added a comment - org.castor.util.CycleBreaker class implementing the thread safe cycle detection methods used in the SourceGenerator patch.
        Hide
        Jim Procter added a comment -

        The attached patch and org.castor.util.CycleBreaker class are sufficient for the test case but cause one basic CTF test to fail:
        ...
        Time: 136.282
        There was 1 failure:
        1) sourcegenerator/Primitives/WithWrappers/Test when using wrapper objects instead of primitives#Test Marshaling with the generated Descriptors_ReferenceDocument(org.castor.xmlctf.TestWithReferenceDocument)junit.framework.AssertionFailedError: The initial reference object and the one resulting of the marshal/unmarshal process are different
        at org.castor.xmlctf.TestWithReferenceDocument.runTest(TestWithReferenceDocument.java:257)
        at org.castor.xmlctf.CastorTestSuiteRunner.main(CastorTestSuiteRunner.java:167)

        FAILURES!!!
        Tests run: 304, Failures: 1, Errors: 0

        I've not yet worked out quite where this is failing, but it is almost certainly due to the patched equals method behaving incorrectly. Hopefully someone more experienced than myself will spot the problem here.

        Show
        Jim Procter added a comment - The attached patch and org.castor.util.CycleBreaker class are sufficient for the test case but cause one basic CTF test to fail: ... Time: 136.282 There was 1 failure: 1) sourcegenerator/Primitives/WithWrappers/Test when using wrapper objects instead of primitives#Test Marshaling with the generated Descriptors_ReferenceDocument(org.castor.xmlctf.TestWithReferenceDocument)junit.framework.AssertionFailedError: The initial reference object and the one resulting of the marshal/unmarshal process are different at org.castor.xmlctf.TestWithReferenceDocument.runTest(TestWithReferenceDocument.java:257) at org.castor.xmlctf.CastorTestSuiteRunner.main(CastorTestSuiteRunner.java:167) FAILURES!!! Tests run: 304, Failures: 1, Errors: 0 I've not yet worked out quite where this is failing, but it is almost certainly due to the patched equals method behaving incorrectly. Hopefully someone more experienced than myself will spot the problem here.
        Hide
        Jim Procter added a comment -

        updated patch to SourceFactory which also passes all CTF tests.

        Show
        Jim Procter added a comment - updated patch to SourceFactory which also passes all CTF tests.
        Hide
        Jim Procter added a comment -

        additional usage javadoc relating to the outstanding CTF failure in the previous version of the SourceFactory patch where cycle breaking was incorrectly applied to identical references to a single string constant shared by the objects being compared.

        Show
        Jim Procter added a comment - additional usage javadoc relating to the outstanding CTF failure in the previous version of the SourceFactory patch where cycle breaking was incorrectly applied to identical references to a single string constant shared by the objects being compared.
        Hide
        Ralf Joachim added a comment -

        Final patch.

        Show
        Ralf Joachim added a comment - Final patch.

          People

          • Assignee:
            Ralf Joachim
            Reporter:
            Jim Procter
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: