---
core/src/com/google/inject/internal/ProxyFactory.java | 6 ++++--
core/test/com/google/inject/MethodInterceptionTest.java | 14 ++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/core/src/com/google/inject/internal/ProxyFactory.java
b/core/src/com/google/inject/internal/ProxyFactory.java
index 0b39f76..07d0045 100644
--- a/core/src/com/google/inject/internal/ProxyFactory.java
+++ b/core/src/com/google/inject/internal/ProxyFactory.java
@@ -20,6 +20,7 @@ import static
com.google.inject.internal.BytecodeGen.newFastClass;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.inject.spi.InjectionPoint;
@@ -135,8 +136,9 @@ final class ProxyFactory<T> implements
ConstructionProxyFactory<T> {
interceptorsMapBuilder = ImmutableMap.builder();
}
- interceptorsMapBuilder.put(pair.method,
ImmutableList.copyOf(pair.interceptors));
- callbacks[i] = new InterceptorStackCallback(pair.method,
pair.interceptors);
+ ImmutableList<MethodInterceptor> deDuplicated =
ImmutableSet.copyOf(pair.interceptors).asList();
+ interceptorsMapBuilder.put(pair.method, deDuplicated);
+ callbacks[i] = new InterceptorStackCallback(pair.method, deDuplicated);
}
interceptors = interceptorsMapBuilder != null
diff --git a/core/test/com/google/inject/MethodInterceptionTest.java
b/core/test/com/google/inject/MethodInterceptionTest.java
index 6fe8b4e..e3bb97e 100644
--- a/core/test/com/google/inject/MethodInterceptionTest.java
+++ b/core/test/com/google/inject/MethodInterceptionTest.java
@@ -313,4 +313,18 @@ public class MethodInterceptionTest extends TestCase {
}
}
+ public void testDeDuplicateInterceptors() throws Exception {
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ CountingInterceptor interceptor = new CountingInterceptor();
+ bindInterceptor(Matchers.any(), Matchers.any(), interceptor);
+ bindInterceptor(Matchers.any(), Matchers.any(), interceptor);
+ }
+ });
+
+ Interceptable interceptable = injector.getInstance(Interceptable.class);
+ interceptable.foo();
+ assertEquals(1, count.get());
+ }
}
--
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.