Hi again,

I don't know that this is a defect, other than a case of needing to know
that an interceptor is a singleton.  If its logic needs to be thread safe
then it can define mutexes appropriately.  I don't know that I'd expect it
to behave any differently :/

-Fred

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