Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upjava.lang.IllegalStateException: stream has already been operated upon or closed #573
Labels
Comments
This comment has been minimized.
This comment has been minimized.
It happens because (in Java 8+) interfaces such as So, to avoid unexpected failures like this, said interfaces should be (and will be) regarded as unmockable. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please provide the following information:
Version of JMockit that was used:
1.44
Description of the problem:
When I use a mocked list of anything, LocalDateTime.now() and make a stream out of a list, an exception occured:
java.lang.IllegalStateException: stream has already been operated upon or closed
Here is a minimal code example (junit-test)
@Test public void whyThisError(@Mocked List<Integer> doNothingWith) { LocalDateTime.now(); Optional<String> any = Arrays.asList("a").stream().findAny(); }
If you comment out LocalDateTime.now() or the mocked List ... no exception occurs
I use openjdk11 and inteliJ as IDE.
Could anybody explain this for me?
Greets
Dennis