reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gyewon Lee <strayyy...@gmail.com>
Subject Re: Tang "ambiguous subplan" exception when using Lists
Date Fri, 22 Jun 2018 00:49:54 GMT
Hi, Sharath. Sorry for my late response.

I have looked at Tang code and found out that for Set and List named
parameters, the default value could be set to empty set or empty list even
though there are no bound default values. I'm not sure on the reason,
though.

I will open an issue in JIRA and send a PR soon.

Best regards,
Gyewon.

2018-06-22 2:20 GMT+09:00 Sharath Malladi <sharathm@microsoft.com.invalid>:

> Hi Gyewon,
>
> Did you get time to investigate this. Could you share your findings.
>
> Thanks,
> Sharath.
>
> -----Original Message-----
> From: Gyewon Lee <strayyyyyy@gmail.com>
> Sent: Monday, June 18, 2018 6:02 PM
> To: dev@reef.apache.org
> Subject: Re: Tang "ambiguous subplan" exception when using Lists
>
> Hi, Sharath.
>
> As you say, it seems you haven't bound anything for "TcpPortList". I will
> look into the Tang code and get back to you after I find the cause.
>
> Best regards,
> Gyewon
>
> 2018-06-19 7:57 GMT+09:00 Sharath Malladi <sharathm@microsoft.com.
> invalid>:
>
> > Hi,
> >
> > If I have a class that has multiple injectors (one of which injects a
> > list), then I get an InjectionException about an "Ambiguous subplan".
> > As you can see from the exception below, it assumes that I attempted
> > to bind to an empty list, which I did not .. so there should be no
> ambiguity.
> >
> > Is there a work around for this issue.
> >
> > Thanks,
> > Sharath.
> >
> > For example, here is the class with two injectors:
> >
> >
> > class TcpPortProvider {
> >   protected final List<String> list;
> >   protected final String s;
> >
> >   @Inject
> >   TcpPortProvider(@Parameter(TcpPortList.class) final List<String>
> > tcpPortList) {
> >     System.out.println("tcpPortList constructor");
> >     this.list = tcpPortList;
> >     this.s = "";
> >   }
> >
> >
> >   @Inject
> >   TcpPortProvider(@Parameter(TcpPortListString.class) final String s) {
> >     System.out.println("TcpPortListString constructor");
> >     this.s = s;
> >     this.list = null;
> >   }
> >
> >   @NamedParameter
> >   static class TcpPortList implements Name<List<String>> {
> >   }
> >
> >   @NamedParameter
> >   static class TcpPortListString implements Name<String> {
> >   }
> > }
> >
> >
> > And here is the code to instantiate using injection where I only
> > supplied argument for the injector that uses the string.
> >
> >
> > final JavaConfigurationBuilder cb = tang.newConfigurationBuilder();
> > cb.bindNamedParameter(TcpProvider.TcpPortListString.class, "this is a
> > string");
> > tang.newInjector(cb.build()).getInstance(TcpPortProvider.class);
> >
> >
> >
> > And here is the exception (note how it indicates that I also bound to
> > an empty list):
> >
> > org.apache.reef.tang.exceptions.InjectionException: Cannot inject
> > org.apache.reef.tang.TcpPortProvider Ambiguous subplan
> > org.apache.reef.tang.TcpPortProvider
> >   new TcpPortProvider(String TcpPortListString = this is a string)
> >   new TcpPortProvider(list {
> >  } )
> > ]
> >
> >                 at org.apache.reef.tang.implementation.java.
> > InjectorImpl.injectFromPlan(InjectorImpl.java:600)
> >                 at org.apache.reef.tang.implementation.java.
> > InjectorImpl.getInstance(InjectorImpl.java:515)
> >                 at org.apache.reef.tang.implementation.java.
> > InjectorImpl.getInstance(InjectorImpl.java:533)
> >                 at org.apache.reef.tang.TestTang.
> > testTcpProvider(TestTang.java:452)
> >                 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > Method)
> >                 at sun.reflect.NativeMethodAccessorImpl.invoke(
> > NativeMethodAccessorImpl.java:62)
> >                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> > DelegatingMethodAccessorImpl.java:43)
> >                 at java.lang.reflect.Method.invoke(Method.java:498)
> >                 at org.junit.runners.model.FrameworkMethod$1.
> > runReflectiveCall(FrameworkMethod.java:47)
> >                 at org.junit.internal.runners.
> > model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> >                 at org.junit.runners.model.FrameworkMethod.
> > invokeExplosively(FrameworkMethod.java:44)
> >                 at org.junit.internal.runners.statements.InvokeMethod.
> > evaluate(InvokeMethod.java:17)
> >                 at org.junit.internal.runners.statements.RunBefores.
> > evaluate(RunBefores.java:26)
> >                 at org.junit.rules.ExpectedException$
> > ExpectedExceptionStatement.evaluate(ExpectedException.java:168)
> >                 at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> >                 at org.junit.runners.ParentRunner.runLeaf(
> > ParentRunner.java:271)
> >                 at org.junit.runners.BlockJUnit4ClassRunner.runChild(
> > BlockJUnit4ClassRunner.java:70)
> >                 at org.junit.runners.BlockJUnit4ClassRunner.runChild(
> > BlockJUnit4ClassRunner.java:50)
> >                 at org.junit.runners.ParentRunner$3.run(
> > ParentRunner.java:238)
> >                 at org.junit.runners.ParentRunner$1.schedule(
> > ParentRunner.java:63)
> >                 at org.junit.runners.ParentRunner.runChildren(
> > ParentRunner.java:236)
> >                 at org.junit.runners.ParentRunner.access$000(
> > ParentRunner.java:53)
> >                 at org.junit.runners.ParentRunner$2.evaluate(
> > ParentRunner.java:229)
> >                 at org.junit.runners.ParentRunner.run(ParentRunner.
> > java:309)
> >                 at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
> >                 at com.intellij.junit4.JUnit4IdeaTestRunner.
> > startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> >                 at com.intellij.rt.execution.
> > junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
> IdeaTestRunner.java:47)
> >                 at com.intellij.rt.execution.junit.JUnitStarter.
> > prepareStreamsAndStart(JUnitStarter.java:242)
> >                 at com.intellij.rt.execution.junit.JUnitStarter.main(
> > JUnitStarter.java:70)
> >
> >
> > Process finished with exit code -1
> >
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message