99soft / rocoto

expanded properties file parsing for Google Guice
http://99soft.github.com/rocoto/
Apache License 2.0
22 stars 12 forks source link

Not working with Guice 4.2.0 #12

Open nsiniakevich opened 6 years ago

nsiniakevich commented 6 years ago

Simple groovy script to reproduce the issue

@Grapes([
        @Grab(group = 'com.google.inject', module = 'guice', version = '4.2.0'),
        @Grab(group = 'org.99soft.guice', module = 'rocoto', version = '6.3')
])
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import org.nnsoft.guice.rocoto.Rocoto;

Injector injector = Guice.createInjector(Rocoto.expandVariables(new AbstractModule() {
    @Override
    protected void configure() {
        Properties properties = new Properties();
        properties.put("JDBC.host", "localhost");
        properties.put("JDBC.port", "3306");
        properties.put("JDBC.schema", "test");

        Names.bindProperties(binder(), properties);
    }
}))

I used code from getting started example http://99soft.github.io/rocoto/getting-started.html

The result is:

java.lang.UnsupportedOperationException: getProvider() not supported for module bindings
    at com.google.inject.internal.BindingImpl.getProvider(BindingImpl.java:73)
    at org.nnsoft.guice.rocoto.Rocoto$2.visit(Rocoto.java:98)
    at org.nnsoft.guice.rocoto.Rocoto$2.visit(Rocoto.java:75)
    at com.google.inject.internal.BindingImpl.acceptVisitor(BindingImpl.java:99)
    at org.nnsoft.guice.rocoto.Rocoto.configure(Rocoto.java:74)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:61)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
    at com.google.inject.spi.Elements.getElements(Elements.java:103)
    at com.google.inject.util.Modules$OverrideModule.configure(Modules.java:195)
    at com.google.inject.AbstractModule.configure(AbstractModule.java:61)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
    at com.google.inject.spi.Elements.getElements(Elements.java:103)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
    ... 4 more

BTW, the same code works with guice 4.1.0.