[jira] Created: (JMOCK-252) Mockery.describeTo() throws ConcurrentModificationException when an invocation's toString() makes another invocation
Richard Barnett (JIRA <
jira@...>
2011-06-01 08:50:22 GMT
Mockery.describeTo() throws ConcurrentModificationException when an invocation's toString() makes
another invocation
--------------------------------------------------------------------------------------------------------------------
Key: JMOCK-252
URL: http://jira.codehaus.org/browse/JMOCK-252
Project: jMock
Issue Type: Bug
Components: JMock 2.x.x Library
Affects Versions: 2.5.1
Reporter: Richard Barnett
Priority: Minor
This can occur when a test has already failed, & JMock is producing its description of what's happened & what
was expected. The exception prevents display of this description, making it hard to work out how the test failed.
Mockery.describeTo:
{code}
public void describeTo(Description description) {
description.appendDescriptionOf(dispatcher)
.appendText("\nwhat happened before this:");
if (actualInvocations.isEmpty()) {
description.appendText(" nothing!");
}
else {
description.appendList("\n ", "\n ", "\n", actualInvocations);
}
}
{code}
If actualInvocations is modified because an invocation's description caused another invocation, then
the iteration in BaseDescription.appendList throws ConcurrentModificationException:
{code}
java.util.ConcurrentModificationException
at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
at java.util.AbstractList$Itr.next(AbstractList.java:343)
at org.hamcrest.BaseDescription.appendList(BaseDescription.java:78)
at org.hamcrest.BaseDescription.appendList(BaseDescription.java:69)
at org.jmock.Mockery.describeTo(Mockery.java:208)
at org.jmock.api.ExpectationError.describeTo(ExpectationError.java:43)
at org.hamcrest.BaseDescription.appendDescriptionOf(BaseDescription.java:21)
at org.hamcrest.StringDescription.toString(StringDescription.java:28)
at org.jmock.lib.AssertionErrorTranslator.translate(AssertionErrorTranslator.java:20)
at org.jmock.Mockery.dispatch(Mockery.java:223)
at org.jmock.Mockery.access$000(Mockery.java:43)
at org.jmock.Mockery$MockObject.invoke(Mockery.java:258)
at org.jmock.internal.InvocationDiverter.invoke(InvocationDiverter.java:27)
at org.jmock.internal.FakeObjectMethods.invoke(FakeObjectMethods.java:38)
at org.jmock.lib.legacy.ClassImposteriser$4.invoke(ClassImposteriser.java:137)
at scratch.ConcurrentModificationExceptionTest$Collaborator$$EnhancerByCGLIB$$11593041.message(<generated>)
at scratch.ConcurrentModificationExceptionTest$Subject.doIt(ConcurrentModificationExceptionTest.java:102)
at scratch.ConcurrentModificationExceptionTest.test(ConcurrentModificationExceptionTest.java:54)
{code}
Possible solutions:
* Pass a copy of actualInvocations to appendList()
* Change Mockery state to ignore further invocations
* Handle this exception
Where the original failure is due to an unexpected invocation, overriding Mockery.describeTo() to do
nothing allows the AssertionError to be displayed.
Attachment reproduces the issue.
--
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email