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

java.lang.IllegalStateException: Duplicate key #1139

Closed
esfomeado opened this issue Jan 7, 2025 · 5 comments
Closed

java.lang.IllegalStateException: Duplicate key #1139

esfomeado opened this issue Jan 7, 2025 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@esfomeado
Copy link
Contributor

esfomeado commented Jan 7, 2025

Describe the bug

java.lang.IllegalStateException: Duplicate key com.navercorp.fixturemonkey.api.generator.ObjectProperty@f659654a (attempted merging values com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode@949c598 and com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode@43d3aba5) 
   at java.base/java.util.stream.Collectors.duplicateKeyException(Collectors.java:135 undefined) 
   at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:182 undefined) 
   at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169 undefined) 
   at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708 undefined) 
   at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509 undefined) 
   at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499 undefined) 
   at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921 undefined) 
   at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234 undefined) 
   at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682 undefined) 
   at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.mergeWithNewChildren(DefaultTraverseNode.java:531 undefined) 
   at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.setMergedChildren(DefaultTraverseNode.java:150 undefined) 
   at com.navercorp.fixturemonkey.api.tree.DefaultTraverseNode.forceExpand(DefaultTraverseNode.java:267 undefined) 
   at com.navercorp.fixturemonkey.tree.ObjectNode.forceExpand(ObjectNode.java:89 undefined) 
   at com.navercorp.fixturemonkey.customizer.NodeSetDecomposedValueManipulator.setValue(NodeSetDecomposedValueManipulator.java:184 undefined) 
   at com.navercorp.fixturemonkey.customizer.NodeSetDecomposedValueManipulator.manipulate(NodeSetDecomposedValueManipulator.java:95 undefined) 
   at com.navercorp.fixturemonkey.customizer.ApplyNodeCountManipulator.manipulate(ApplyNodeCountManipulator.java:36 undefined) 
   at com.navercorp.fixturemonkey.tree.ObjectTree.manipulate(ObjectTree.java:60 undefined) 
   at com.navercorp.fixturemonkey.customizer.ArbitraryManipulator.manipulate(ArbitraryManipulator.java:46 undefined) 
   at com.navercorp.fixturemonkey.resolver.ArbitraryResolver.lambda$resolve$3(ArbitraryResolver.java:96 undefined) 
   at com.navercorp.fixturemonkey.resolver.ResolvedCombinableArbitrary.lambda$new$0(ResolvedCombinableArbitrary.java:64 undefined) 
   at com.navercorp.fixturemonkey.api.lazy.UnSafeLazyArbitraryImpl.getValue(UnSafeLazyArbitraryImpl.java:53 undefined) 
   at com.navercorp.fixturemonkey.resolver.ResolvedCombinableArbitrary.combined(ResolvedCombinableArbitrary.java:75 undefined) 
   at com.navercorp.fixturemonkey.builder.DefaultArbitraryBuilder.sample(DefaultArbitraryBuilder.java:483 undefined)

Your environment

  • Fixture Monkey: 1.1.7 (This also happens on versions 1.1.4, 1.1.5 and 1.1.8). Versions 1.1.2 and 1.1.6 work fine
  • Java 21

Steps to reproduce

I´m unable to create a replication for this issue.
This is a 1:1 copy of my production code but here it works as expected but it fails in my production code so I have no idea what causes this issue.

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L254

Expected behaviour

Should generate the value

Actual behaviour

It throws an exception

@esfomeado esfomeado added the bug Something isn't working label Jan 7, 2025
@seongahjo
Copy link
Contributor

seongahjo commented Jan 8, 2025

@esfomeado
Hi, I cannot reproduce the error either.

Can you tell me the JDK version or vendor of your production code? It may be related to a specific JDK version or vendor.

Thank you.

@esfomeado
Copy link
Contributor Author

@seongahjo Java 21.0.5 Temurin

I will keep trying to recreate the issue as well.

@esfomeado
Copy link
Contributor Author

@seongahjo I was able to replicate the issue.

https://github.com/esfomeado/fixture-monkey-bug/blob/master/src/test/java/com/example/bug/FixtureMonkeyTest.java#L269

Seems to be due to how I set up the interface plugin

@seongahjo
Copy link
Contributor

seongahjo commented Jan 10, 2025

@esfomeado
Hi, I noticed that you have used the InterfaceCandidateConcretePropertyResolver to resolve the interface type.
I recommend you to use the ConcreteTypeCandidateConcretePropertyResolver instead.

InterfaceCandidateConcretePropertyResolver is a replacement for InterfaceObjectPropertyGenerator but it is no longer needed. It will be deprecated in 1.1.9 and I'll make that clear in the document.

Thank you for reporting an issue!

@seongahjo seongahjo modified the milestones: 1.0.30, 1.1.9 Jan 10, 2025
@esfomeado
Copy link
Contributor Author

@seongahjo Thanks the issue has been fixed after switching to the ConcreteTypeCandidateConcretePropertyResolver

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