Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In a multithreaded environment, when using giveMeOne, ConcurrentModificationException and JqwikException exceptions will occur. #1049

Open
NinthCode opened this issue Sep 10, 2024 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@NinthCode
Copy link

Describe the bug

In a multithreaded environment, when using giveMeOne, ConcurrentModificationException and JqwikException exceptions will occur.

Your environment

  • Fixture Monkey 1.0.21
  • Java 17

Steps to reproduce

` @test
public void test() throws Exception {
CountDownLatch latch = new CountDownLatch(100);
CountDownLatch mLatch = new CountDownLatch(100);
for (int i = 0; i < 100; i++) {
final Integer ii = i;
new Thread(() -> {
try {
latch.await();
FixtureMonkey fixtureMonkey = FixtureMonkey.builder().defaultNotNull(true).objectIntrospector(FieldReflectionArbitraryIntrospector.INSTANCE).build();
System.out.println(ii + JSON.toJSONString(fixtureMonkey.giveMeOne(tt.class)));
} catch (Exception e) {
e.printStackTrace();
} finally {
mLatch.countDown();
}
}).start();
latch.countDown();
}
mLatch.await();
}

@Data
public static class tt {
    public String name;
}`

Expected behaviour

Running normally.

Actual behaviour

java.util.ConcurrentModificationException at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221) at net.jqwik.engine.execution.lifecycle.StoreRepository.addStore(StoreRepository.java:56) at net.jqwik.engine.execution.lifecycle.StoreRepository.create(StoreRepository.java:51) at net.jqwik.engine.facades.StoreFacadeImpl.create(StoreFacadeImpl.java:19) at net.jqwik.api.lifecycle.Store.create(Store.java:67)
and
net.jqwik.api.JqwikException: You cannot create Store(net.jqwik.engine.facades.Memoize, PROPERTY, [jqwik:samples]): [null] with identifier [class net.jqwik.engine.facades.Memoize]. It conflicts with existing Optional[Store(net.jqwik.engine.facades.Memoize, PROPERTY, [jqwik:samples]): [{}]] at net.jqwik.engine.execution.lifecycle.StoreRepository.lambda$addStore$2(StoreRepository.java:72) at java.base/java.util.Optional.ifPresent(Optional.java:178) at net.jqwik.engine.execution.lifecycle.StoreRepository.addStore(StoreRepository.java:65) at net.jqwik.engine.execution.lifecycle.StoreRepository.create(StoreRepository.java:51) at net.jqwik.engine.facades.StoreFacadeImpl.create(StoreFacadeImpl.java:19)

@NinthCode NinthCode added the bug Something isn't working label Sep 10, 2024
@seongahjo seongahjo added this to the 1.0.25 milestone Sep 11, 2024
@seongahjo
Copy link
Contributor

@NinthCode
Hello, it is fixed in 1.0.25.

Please check that the problem has been resolved.
Let me know if there is another problem.

Thank you.

@NinthCode
Copy link
Author

@NinthCode Hello, it is fixed in 1.0.25.

Please check that the problem has been resolved. Let me know if there is another problem.

Thank you.

@seongahjo
Hello! Thank you for your fix. It seems that the problem has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants