This is not an issue to be "fixed". You just have to consider the
thread-safety of interceptors like you would any other object you write,
with additional consideration to the fact that a single interceptor can be
intercepting for multiple objects at the same time depending on what it's
set up to intercept and how those bindings are scoped. Generally, you should
probably write interceptors that are completely thread-safe.

Colin


On Mon, Jan 24, 2011 at 10:17 AM, Anthony MULLER
<[email protected]>wrote:

> Thanks very much for your reply. Do you know if this issue is tracked?
>
> Is it fixed in Guice 2.0?
>
> Regards,
> Anthony MÜLLER
>
>
> 2011/1/24 Fred Faber <[email protected]>:
> > Your suspicions are correct:  an interceptor may be invoked by several
> > threads concurrently.  For instance:
> > class TimingInterceptor implements MethodInterceptor {
> >   private final Stopwatch stopwatch;
> >
> >    TimingInterceptor(Stopwatch stopwatch) {
> >        this.stopwatch = stopwatch;
> >     }
> >   @Override Object invoke(MethodInvocation i) throws Throwable {
> >        stopwatch.reset();
> >        try {
> >          return i.proceed();
> >        } finally {
> >           System.err.println("Invocation time: " + stopwatch.get());
> >       }
> >   }
> > Is going to break, because the stopwatch is shared among threads.
> > -Fred
> > On Mon, Jan 24, 2011 at 9:46 AM, Anthony MULLER <
> [email protected]>
> > wrote:
> >>
> >> Hello,
> >>
> >> I'm using "method interceptor" mechanisms with Guice 1.0 and I wish to
> >> know if it is thread-safe? (I have some strange behaviours in
> >> multithreading environment)
> >>
> >> Regards,
> >> Anthony MÜLLER
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "google-guice" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<google-guice%[email protected]>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/google-guice?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "google-guice" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-guice%[email protected]>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/google-guice?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-guice%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-guice?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en.

Reply via email to