fixture-monkey icon indicating copy to clipboard operation
fixture-monkey copied to clipboard

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

Open NinthCode opened this issue 1 year ago • 2 comments

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 avatar Sep 10 '24 07:09 NinthCode

@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 avatar Sep 11 '24 11:09 seongahjo

@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.

NinthCode avatar Sep 12 '24 06:09 NinthCode