murdos / easy-random-protobuf

Easy Random protobuf support
Apache License 2.0
11 stars 7 forks source link

"StackOverflowError" and "Unable to create a random instance of type class <Compiled Protobuf Class>" #136

Open grimsi opened 2 years ago

grimsi commented 2 years ago

First of all thanks for this plugin, it seems to be really helpful!

Sadly I have some problems to get it working in my project, I always get the following error message: org.jeasy.random.ObjectCreationException: Unable to create a random instance of type class com.igdb.proto.Igdb$InvolvedCompany

I uploaded a small sample project to reproduce this error here: https://github.com/grimsi/easyrandom-protobuf-test Simply running a mvn clean install will result in a Stack-Overflow and "Unable to create a random instance of type class XXX".

I am using the official protobuf file from IGDB and it works fine in my project: https://api.igdb.com/v4/igdbapi.proto I am using the protoc-jar-maven-plugin to compile the .proto file to Java classes. My project is using Java 18 (maybe that's an issue?).

If you need any further assistance just tell me and I will give my best to support you.

murdos commented 1 year ago

@grimsi : sorry for the (very) late answer. Could you try with the 1.0.0 snapshot version? I've done a internal rewrite with https://github.com/murdos/easy-random-protobuf/pull/170 that might resolve your issue.

grimsi commented 1 year ago

Thanks for replying! Sadly the bug is still present. I tested it using my grimsi/easyrandom-protobuf-test repository.

With easy-random-protobuf 1.0.0-SNAPTHOT and easy-random-core 6.0.0-SNAPSHOT I get the same error as before (StackOverflow).

With easy-random-protobuf 1.0.0-SNAPSHOT and easy-random-core 5.0.0 I get the following error: Cannot invoke "org.jeasy.random.api.RandomizerProvider.getRandomizerByType(java.lang.Class, org.jeasy.random.api.RandomizerContext)" because the return value of "org.jeasy.random.EasyRandomParameters.getRandomizerProvider()" is null

murdos commented 1 year ago

Thanks. I've been able to reproduce the issue and created a minimal test case that illustrates the infinite recursion issue. See #177. However the fix it still doesn't work on your test case although it now behaves differently (the object generation never ends...) To be continued...