reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sharath Malladi <>
Subject Tang "ambiguous subplan" exception when using Lists
Date Mon, 18 Jun 2018 22:57:04 GMT

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.


For example, here is the class with two injectors:

class TcpPortProvider {
  protected final List<String> list;
  protected final String s;

  TcpPortProvider(@Parameter(TcpPortList.class) final List<String> tcpPortList) {
    System.out.println("tcpPortList constructor");
    this.list = tcpPortList;
    this.s = "";

  TcpPortProvider(@Parameter(TcpPortListString.class) final String s) {
    System.out.println("TcpPortListString constructor");
    this.s = s;
    this.list = null;

  static class TcpPortList implements Name<List<String>> {

  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");

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.TestTang.testTcpProvider(
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(
                at java.lang.reflect.Method.invoke(
                at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
                at org.junit.runners.model.FrameworkMethod.invokeExplosively(
                at org.junit.internal.runners.statements.InvokeMethod.evaluate(
                at org.junit.internal.runners.statements.RunBefores.evaluate(
                at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(
                at org.junit.rules.RunRules.evaluate(
                at org.junit.runners.ParentRunner.runLeaf(
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(
                at org.junit.runners.BlockJUnit4ClassRunner.runChild(
                at org.junit.runners.ParentRunner$
                at org.junit.runners.ParentRunner$1.schedule(
                at org.junit.runners.ParentRunner.runChildren(
                at org.junit.runners.ParentRunner.access$000(
                at org.junit.runners.ParentRunner$2.evaluate(
                at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(
                at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
                at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(
                at com.intellij.rt.execution.junit.JUnitStarter.main(

Process finished with exit code -1

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