Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#63 Calling .toString() on Diff runs .compare()

Java 1.6
closed-fixed
nobody
None
5
2014-12-31
2014-02-24
Chris Dombroski
No

Having .compare() run from .toString() can cause unintended side effects such as comparing the documents before a difference listener is set. Suggest returning the comparison result only if the comparison has already been run and returning some form of "comparison not yet run" otherwise.

Discussion

  • Stefan Bodewig
    Stefan Bodewig
    2014-03-03

    The problem for 1.x is backwards compatibility of course. The choice of having toString run the comparison has been made very long ago and I don't think we can resonable remove that from 1.x. What I can do is add some warnings to the documentation.

    Since you've added this issue to 2.x - the only place we currently have Diff is within the legacy component which is only there for a 1.x backwards compatible API, I'd leave it as it is for the same reasons as in 1.x. The "real 2.x" API forces you to trigger the comparions explicitly.

     
  • Ah, the versioning thing would be confusion on my part. I thought it referred to the Java version not the version of XMLUnit; the problem was noticed in XMLUnit 1.5

    If the 1.x line is going to remain the way it is for compatibility and the problem is already being addressed in the 2.x API then I suppose we can mark this bug closed.

     
  • Stefan Bodewig
    Stefan Bodewig
    2014-03-03

    well, 2.0 is still some way from getting released and the longer I wait with taking the final steps the less likely it becomes.

    I'll still leave this issue open until I've found time to update the online users-guide and javadocs with some hints about the implicit compare invocation.

     
  • Stefan Bodewig
    Stefan Bodewig
    2014-12-14

    • Group: Java 2.x --> Java 1.5
     
  • Stefan Bodewig
    Stefan Bodewig
    2014-12-30

    • status: open --> pending-fixed
    • Group: Java 1.5 --> Java 1.6
     
  • Stefan Bodewig
    Stefan Bodewig
    2014-12-30

    Documented with svn revision 582 - https://sourceforge.net/p/xmlunit/code/582/ - documentation on the website will change with the 1.6 release which should happen within the next days.

     
  • Stefan Bodewig
    Stefan Bodewig
    2014-12-31

    • status: pending-fixed --> closed-fixed