jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
465 stars 240 forks source link

IndexOutOfBoundsException when getting mocked instances #16

Closed rfer closed 10 years ago

rfer commented 10 years ago

After upgrading from 1.0 to 1.9, I started getting these IndexOutOfBoundsExceptions. Here is the relevant part of the exception:

java.lang.IndexOutOfBoundsException: Index: 10, Size: 7 at java.util.ArrayList.rangeCheck(ArrayList.java:638) at java.util.ArrayList.get(ArrayList.java:414) at mockit.internal.state.MockInstances.getMock(MockInstances.java:27) at mockit.internal.state.MockClasses.getMock(MockClasses.java:39) at mockit.internal.state.TestRun.getMock(TestRun.java:119)

This is happening on a large project with lots of submodules. When testing all of them this exception is thrown, but if running them individually there is no problem.

Unfortunately I've been unable to isolate and reproduce this on a separate test, so it's hard to have an idea about what might be causing this.

I tried to downgrade to 1.8 and the number of exceptions went from 11 in 850 tests to about 200.

rliesenfeld commented 10 years ago

Unfortunately, this stack trace doesn't tell my anything useful about the problem. If I can reproduce it, I will fix it immediately, though. If you manage to find a reproducing example test, please let me know.

hellonico commented 9 years ago

Getting something similar. Whats not so great is that it is hanging the build entirely. Any idea where to start looking ?

Unexpected exception thrown. java.lang.IndexOutOfBoundsException: Index: 5, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at mockit.internal.util.Utilities.indexOfReference(Utilities.java:105) at mockit.internal.util.Utilities.containsReference(Utilities.java:99) at mockit.internal.state.ExecutingTest.isMockedInstance(ExecutingTest.java:182) at mockit.internal.expectations.ExecutionMode$3.isToExecuteRealImplementation(ExecutionMode.java:47) at mockit.internal.expectations.RecordAndReplayExecution.defaultReturnValue(RecordAndReplayExecution.java:241) at mockit.internal.expectations.RecordAndReplayExecution.recordOrReplay(RecordAndReplayExecution.java:189) at mockit.internal.expectations.mocking.MockedBridge.invoke(MockedBridge.java:63) at java.util.AbstractList.iterator(AbstractList.java) at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:282) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662) Unexpected exception thrown. java.lang.IndexOutOfBoundsException: Index: 4, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at mockit.internal.util.Utilities.indexOfReference(Utilities.java:105) at mockit.internal.util.Utilities.containsReference(Utilities.java:99) at mockit.internal.state.ExecutingTest.isMockedInstance(ExecutingTest.java:182) at mockit.internal.expectations.ExecutionMode$3.isToExecuteRealImplementation(ExecutionMode.java:47) at mockit.internal.expectations.RecordAndReplayExecution.defaultReturnValue(RecordAndReplayExecution.java:241) at mockit.internal.expectations.RecordAndReplayExecution.recordOrReplay(RecordAndReplayExecution.java:189) at mockit.internal.expectations.mocking.MockedBridge.invoke(MockedBridge.java:63) at java.util.AbstractList.iterator(AbstractList.java) at org.gradle.messaging.remote.internal.hub.MessageHub$ConnectionDispatch.run(MessageHub.java:282) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) at java.lang.Thread.run(Thread.java:662)

rliesenfeld commented 9 years ago

How would I reproduce this failure? Any example test?