Awesome, thanks much.
On Wed, Nov 6, 2013 at 4:35 PM, Tavian Barnes <[email protected]> wrote: > Done! https://code.google.com/p/google-guice/issues/detail?id=779 > > > On Wednesday, November 6, 2013 4:22:49 PM UTC-5, Sam Berlin wrote: > >> Hey Tavis, could you file these as issues on the issue site @ >> https://code.google.com/p/google-guice/issues/list and attach the >> patches as separate files? Thanks! >> >> sam >> >> >> On Wed, Nov 6, 2013 at 4:17 PM, Tavian Barnes <[email protected]>wrote: >> >>> If a binding has two equivalent ProvisionListeners, only fire one of >>> them. >>> --- >>> .../inject/internal/ProvisionListenerStackCallback.java | 9 >>> ++++++--- >>> core/test/com/google/inject/ProvisionListenerTest.java | 13 >>> +++++++++++++ >>> 2 files changed, 19 insertions(+), 3 deletions(-) >>> >>> diff --git a/core/src/com/google/inject/internal/ >>> ProvisionListenerStackCallback.java b/core/src/com/google/inject/ >>> internal/ProvisionListenerStackCallback.java >>> index a99c513..45347f0 100644 >>> --- a/core/src/com/google/inject/internal/ProvisionListenerStackCallback >>> .java >>> +++ b/core/src/com/google/inject/internal/ProvisionListenerStackCallback >>> .java >>> @@ -16,14 +16,16 @@ >>> >>> package com.google.inject.internal; >>> >>> +import java.util.List; >>> +import java.util.Set; >>> + >>> import com.google.common.collect.ImmutableList; >>> +import com.google.common.collect.Sets; >>> import com.google.inject.Binding; >>> import com.google.inject.ProvisionException; >>> import com.google.inject.spi.DependencyAndSource; >>> import com.google.inject.spi.ProvisionListener; >>> >>> -import java.util.List; >>> - >>> /** >>> * Intercepts provisions with a stack of listeners. >>> * >>> @@ -49,7 +51,8 @@ final class ProvisionListenerStackCallback<T> { >>> if (listeners.isEmpty()) { >>> this.listeners = EMPTY_LISTENER; >>> } else { >>> - this.listeners = listeners.toArray(new >>> ProvisionListener[listeners.size()]); >>> + Set<ProvisionListener> deDuplicated = Sets.newLinkedHashSet( >>> listeners); >>> + this.listeners = deDuplicated.toArray(new ProvisionListener[ >>> deDuplicated.size()]); >>> } >>> } >>> >>> diff --git a/core/test/com/google/inject/ProvisionListenerTest.java >>> b/core/test/com/google/inject/ProvisionListenerTest.java >>> index 478949f..54a11fa 100644 >>> --- a/core/test/com/google/inject/ProvisionListenerTest.java >>> +++ b/core/test/com/google/inject/ProvisionListenerTest.java >>> @@ -694,4 +694,17 @@ public class ProvisionListenerTest extends TestCase >>> { >>> this.x = xProvider.get(); >>> } >>> } >>> + >>> + public void testDeDuplicateProvisionListeners() { >>> + final Counter counter = new Counter(); >>> + Injector injector = Guice.createInjector(new AbstractModule() { >>> + @Override >>> + protected void configure() { >>> + bindListener(Matchers.any(), counter); >>> + bindListener(Matchers.any(), counter); >>> + } >>> + }); >>> + injector.getInstance(Many.class); >>> + assertEquals("ProvisionListener not de-duplicated", 1, >>> counter.count); >>> + } >>> } >>> -- >>> 1.8.4.2 >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "google-guice" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> >>> Visit this group at http://groups.google.com/group/google-guice. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/google-guice. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-guice. For more options, visit https://groups.google.com/groups/opt_out.
