Don't bind non-annotated types into DynamicSet, DynamicMap
When attaching implementations into a DynamicSet or DynamicMap,
only connect ones bound with an annotation. This enables code to
bind the interface twice, for example:
  class GroupModule extends AbstractModule {
	protected void configure() {
      DynamicSet.setOf(binder(), GroupBackend.class);
      DynamicSet.bind(binder(), GroupBackend.class).to(LdapBackend.class);
      bind(GroupBackend.class).to(UniversalBackend.class);
	}
  }
  class UniversalBackend implements GroupBackend {
    @Inject
	UniversalBackend(DynamicSet<GroupBackend> all) {
	}
  }
Without this no-annotation filter, the universal backend would
be added to its own DynamicSet and create a possible infinite
recursion scenario.
Change-Id: Ifcf08cc577acc7fc31d4eef0465d485e8878f4fc
			
			
This commit is contained in:
		| @@ -258,6 +258,9 @@ public class PluginGuiceEnvironment { | ||||
|         @SuppressWarnings("unchecked") | ||||
|         Binding<Object> b = (Binding<Object>) binding; | ||||
|         Key<Object> key = b.getKey(); | ||||
|         if (key.getAnnotation() == null) { | ||||
|           continue; | ||||
|         } | ||||
|  | ||||
|         @SuppressWarnings("unchecked") | ||||
|         ReloadableRegistrationHandle<Object> h = | ||||
| @@ -323,6 +326,9 @@ public class PluginGuiceEnvironment { | ||||
|         @SuppressWarnings("unchecked") | ||||
|         Binding<Object> b = (Binding<Object>) binding; | ||||
|         Key<Object> key = b.getKey(); | ||||
|         if (key.getAnnotation() == null) { | ||||
|           continue; | ||||
|         } | ||||
|  | ||||
|         @SuppressWarnings("unchecked") | ||||
|         ReloadableRegistrationHandle<Object> h1 = | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Shawn O. Pearce
					Shawn O. Pearce