bineanzhou / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

bindConstant().annotatedWith(clazz).to(null) causes ambigious error message #256

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is not a bug, but an enhancement request.

If I have "bindConstants().annotatedWith(clazz).to(null)" in my code, the
exception thrown will be:

java.lang.NullPointerException: value
        at com.google.inject.util.Objects.nonNull(Objects.java:35)
        at com.google.inject.ConstantFactory.<init>(ConstantFactory.java:30)
        at
com.google.inject.ConstantBindingBuilderImpl$BindingInfo.createBinding(ConstantB
indingBuilderImpl.java:161)
        at
com.google.inject.ConstantBindingBuilderImpl.createBinding(ConstantBindingBuilde
rImpl.java:141)
        at
com.google.inject.BinderImpl.createConstantBinding(BinderImpl.java:355)
        at
com.google.inject.BinderImpl.createConstantBindings(BinderImpl.java:349)
        at com.google.inject.BinderImpl.createInjector(BinderImpl.java:249)
        at com.google.inject.Guice.createInjector(Guice.java:79)
        at com.google.inject.Guice.createInjector(Guice.java:53)
        at com.google.inject.Guice.createInjector(Guice.java:43)

If the codebase is full of constant bindings, this message is ambigious,
because it doesn't tell _which_ binding was the problem. Normally the error
messages Guice provides are excellent and very nicely point to the real
reason behind any exception. It'd be good idea to provide a more accurate
error message also in this case.

Original issue reported on code.google.com by juha.myn...@gmail.com on 6 Oct 2008 at 8:31

GoogleCodeExporter commented 9 years ago
Fixed by r658
http://code.google.com/p/google-guice/source/detail?r=658

Original comment by limpbizkit on 2 Nov 2008 at 9:38