One of our integration tests fails with a NoSuchElementException escaping from CompareMatcher#describeTo(Description). We use org.xmlunit:xmlunit-matchers:2.5.0.
In the debugger, I can see that the matcher's diffResult is != null, but diffResult.hasDifferences() == false. Since describeTo(Description) only checks for diffResult == null, the code flow enters ComparisonMatcher#firstComparison() where the subexpression diffResult.getDifferences().iterator().next() throws the NoSuchElementException.
The fix seems easy: Simply test for diffResult == null || !diffResult.hasDifferences() at the beginning of CompareMatcher#describeTo(Description).
One of our integration tests fails with a
NoSuchElementExceptionescaping fromCompareMatcher#describeTo(Description). We use org.xmlunit:xmlunit-matchers:2.5.0.In the debugger, I can see that the matcher's
diffResultis!= null, butdiffResult.hasDifferences() == false. SincedescribeTo(Description)only checks fordiffResult == null, the code flow entersComparisonMatcher#firstComparison()where the subexpressiondiffResult.getDifferences().iterator().next()throws theNoSuchElementException.The fix seems easy: Simply test for
diffResult == null || !diffResult.hasDifferences()at the beginning ofCompareMatcher#describeTo(Description).