java - "Please wait until after injection has completed to use this object" error from Guice -


we have 2 singleton objects (declared via in(scopes.singleton)) in guice each uses other in constructor. guice's way implement proxies - initializes object @ first proxy other object, , when object needed resolved.

when running code several threads, following exception:

java.lang.illegalstateexception: proxy used support circular references involving constructors. object we're proxying not constructed yet. please wait until after injection has completed use object.     @ com.google.inject.internal.constructioncontext$delegatinginvocationhandler.invoke(constructioncontext.java:100) 

i assume bug in guice, because aren't doing out of ordinary. 1 workaround found initializing singletons using .aseagersingleton(), not convenient, testing example.

is known issue? reported issue google guice, reproduces standalone test.

any other suggestions/workaround?

did try injecting provider<t> in each constructor instead of actual instances?

if don't need other instance in code of constructor, store provider final field, , use field later on (by calling get()).


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -