History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: UNI-126
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Filip Neven
Reporter: James Davis
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Unitils

Usage of nested mocks can cause unexpected behavior (crashed jvm, non-linear execution time)

Created: 04/May/09 01:12 AM   Updated: 08/Jun/09 02:21 AM
Component/s: core
Affects Version/s: 2.2
Fix Version/s: 2.3

File Attachments: 1. Text File hs_err_pid32404.log (61 kb)
2. Java Source File UnitilsBugTestCase.java (2 kb)

Environment: Sun java 5 - 32 & 64 bit jvm.


 Description  « Hide
When having nested classes that are setup with mocks, simple executions get very slow. In some cases I have even had it crash the jvm

 All   Comments   Change History      Sort Order:
James Davis - 04/May/09 01:14 AM
This test case can be used to duplicate this bug. I was unable to duplicate a crash with it as yet (test is still running though). The first 10 passes ran somewhat quickly, but after 10, they get very very slow. Each new one takes as long as the previous one plus more time (I don't think it's quite exponential, but it doesn't seem right at all). The test has been running for about 5 minutes and only gotten upto 15 iterations.

James Davis - 04/May/09 01:16 AM
The test case I submitted has some simple case objects. In my actual project I'm working on, the objects are much larger and it crashes on a similar test after about 4-5 executions. It may be related to overall size of the classes.

James Davis - 04/May/09 01:18 AM
I don't know if this will be of any usefulness, but I've also attached the java crash report.

Filip Neven - 05/May/09 06:36 AM
Thanks man, especially the attached testcase made this bug easy to spot.
The reason for this behavior is the following: During the execution of methods on mock objects, parameters and return values are cloned (using a custom written deep-clone mechanism): this way, we can compare with the objects at invocation time when doing asserts and output the values at invocation time in error messages. Since in your test the return value is a mock object itself, and the mock object contains a reference to the 'Scenario' object, which in turn contains a reference to all cloned values, the amount of objects that is copied doubles during each iteration in your loop.

I will fix this issue asap.
Filip

James Davis - 08/Jun/09 02:21 AM
I can confirm this is fixed in 2.3.

Thanks, this really helps.