Does Provider<Foo> call un-annotated default constructors?

41 views
Skip to first unread message

Kevin Burton

unread,
Apr 6, 2015, 3:16:28 PM4/6/15
to google...@googlegroups.com
I just ran into this today and think it might be a bug?

I have a Provider<Foo> which kind of implies that it would be explicitly setup in a binding.

But it looks like the default constructor was being called.

This was giving me an non-started ActiveMQ broker which wasn't working.

Doesn't Provider sort of imply that it's going to be explicitly provided?  Doing this implicitly seems like it's just prone to bugs.

I prefer Guice to fail fast ...is there a way do disable some of this?

Nate Bauernfeind

unread,
Apr 6, 2015, 3:21:18 PM4/6/15
to google...@googlegroups.com
You probably want to call:

binder.requireExplicitBindings() in your Guice Module to catch these kinds of errors earlier than later.

There are other methods that might solve your needs (like requireAtInjectOnConstructors), see:

--
You received this message because you are subscribed to the Google Groups "google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-guice...@googlegroups.com.
To post to this group, send email to google...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-guice/5a00ad7b-a9d0-4f70-bf5d-5b7ff5d92b73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Boudreau

unread,
Apr 6, 2015, 6:10:18 PM4/6/15
to google...@googlegroups.com
Show us the code - it's not clear what your problem is.  Whose default constructor is being called - Foo or the provider you wrote?  Or did you not write a provider?

-Tim

Kevin Burton

unread,
Apr 6, 2015, 9:42:54 PM4/6/15
to google...@googlegroups.com
NICE ... that's probably just what I need!
Reply all
Reply to author
Forward
0 new messages