All,

There's a 3 year old issue (issue
252<http://code.google.com/p/google-guice/issues/detail?id=252>)
about Guice AOP calling an interceptor twice if there's a synthetic method
inserted into the call-chain.  What does this mean?  Consider the classes:

*   interface HotDog { }
   class NathansDog implements HotDog { }

   interface Store {
     HotDog cookDog();
   }
   class NathansStore implements Store {
     NathansDog cookDog();
   }*

If you have an instance of '*Store*' and call '*myStore.cookDog();*', then
you are actually calling:
  * Store.cookDog()*  <-- synthetic method typed to return *HotDog*
   *NathansStore.cookDog();* <-- normal method, typed to return *NathansDog*

But, that only will happen if *myStore *is typed as '*Store*'.  If it's
typed as '*NathansStore*', then the synthetic method is not called.

If you method matcher for an interceptor is broad, it could be called twice
for one call to *cookDog*, because of the synthetic method!

There are a few possible solutions to this, none of which are really all
that good in my opinion:

 a) Do nothing
     The Good: Status quo.  The bug's been open for 3 years and hasn't had a
single comment, so it can't matter too much.  Right?
     The Bad: It doesn't feel right to call an interceptor twice for one
method.

 b) Never call an interceptor for synthetic methods.
     The Good: Problem goes away.
     The Bad: If the interceptor was only targeting methods that returned '*
HotDog*', it will never be called at all now!
     Why the bad may not be so bad: If people referenced *Store* as *
NathansStore* and the interceptor was typed to want *HotDog*, the
interceptor wouldn't have been called anyway.

 c) Do some fancy footwork when building the injector & matching methods to
interceptors, and deduplicate synthetic/normal methods as much as possible
in terms of matching interceptors.
     The Good: It should end up working as people would expect.
     The Bad: Building the injector has to do even more work and take
marginally longer.  It also leaves open the strange situation where you can
build an interceptor that only *sometimes* gets called, depending on what
the variable type of the caller is.


Thoughts?

sam

-- 
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