Statary / google-gin

Automatically exported from code.google.com/p/google-gin
0 stars 0 forks source link

assisted inject and GinAdapterModule cause UnsupportedOperationException #172

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to reuse a GinModule on the server side where Guice is used. For 
that I am using the install( new GinModuleAdapter( new MyGinModule());

This seems to have impact on other bindings that use Assisted Inject.

This breaks in GIN 1.5, but I have build GIN from trunk (a few weeks ago) and 
there it seems to work fine. I could not find an issue in the trackers that 
might explain... 

But anyway: this is an important issue for me since I am not allowed to use a 
self-build from trunk version of GIN due to company policy.

What is the expected output? What do you see instead?
INFO: An exception was caught and reported. Message: 
java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
       at java.util.AbstractCollection.add(AbstractCollection.java:221)
       at com.google.gwt.inject.rebind.adapter.BinderAdapter.install(BinderAdapter.java:59)
       at com.google.gwt.inject.client.AbstractGinModule.install(AbstractGinModule.java:55)
       at com.swift.editor.shared.SharedEditorModule.configure(SharedEditorModule.java:73)
       at com.google.gwt.inject.client.AbstractGinModule.configure(AbstractGinModule.java:33)
       at com.google.gwt.inject.rebind.adapter.GinModuleAdapter.configure(GinModuleAdapter.java:49)
       at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
       at com.google.inject.AbstractModule.install(AbstractModule.java:118)
       at com.swift.sawa.messenger.MessengerEJBModule.xml(MessengerEJBModule.java:224)
       at com.swift.sawa.messenger.MessengerEJBModule.configure(MessengerEJBModule.java:186)
       at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
       at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
       at com.google.inject.spi.Elements.getElements(Elements.java:101)
       at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
       at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
       at com.google.inject.Guice.createInjector(Guice.java:95)
       at com.google.inject.Guice.createInjector(Guice.java:72)
       at com.google.inject.Guice.createInjector(Guice.java:62)

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by david.nouls on 27 Feb 2012 at 2:45

GoogleCodeExporter commented 9 years ago
I also met exactly the same problem, i'm using gwt-test-util with gin support, 
and i use assist in the gin module.

Original comment by julyg...@gmail.com on 2 Mar 2012 at 5:21

GoogleCodeExporter commented 9 years ago
Forgot to mention:
There is a workaround, don't use the GinModuleAdaptor( Module ) but use the 
constuctor with the second Set<FactoryModule> parameter and make sure you 
provide it with a modifiable Set.

Original comment by david.nouls on 2 Mar 2012 at 7:34

GoogleCodeExporter commented 9 years ago
I have the same issue, and when I try the workaround I get tons of errors 
saying that all my factories are not bound.  I tried looking through the 
source, and it looks like the gin factory modules are never used for binding.  
How do I get around this?

Original comment by toucansa...@gmail.com on 3 Apr 2012 at 11:23

GoogleCodeExporter commented 9 years ago
As described in my comment 2. Use new GinModuleAdapter( module, new 
HashSet<FactoryModule>()). This will break when a new GIN is released, but at 
that time you can remove the second parameter again since it seems to be fixed 
in trunk.

Original comment by david.nouls on 4 Apr 2012 at 6:43

GoogleCodeExporter commented 9 years ago
I have the same problem as toucansam99. The workaround by David doesn't work 
for me. The factories for assisted injection work fine in Gin, but are not 
present Guice. I've also tried using the latest trunk (r241) build, but the 
problem still remains.
Maybe this feature has just not been implemented yet. I've tried looking 
through the latest source code, but all I could find was some code "filtering 
out fake factory modules" (in BinderAdapter#install(GinModule)), which is never 
called by the GinModuleAdapter.
Does someone have a fix/patch or a reasonable workaround?

Original comment by johannes...@googlemail.com on 17 Apr 2012 at 7:45

GoogleCodeExporter commented 9 years ago
Still a problem in Gin 2.1.2 - assisted injection just won't work in Guice 
using GinModuleAdaptor.  The suggested workaround of supplying an empty 
Set<FactoryModule> won't work any more because now the GinModuleAdaptor 
constructor wants a GinjectorBindings object, and I don't see how to make one 
of those. :-(

Original comment by roy.pate...@gmail.com on 4 Dec 2013 at 12:52