Announcement Announcement Module
Collapse
No announcement yet.
ThrowsAdvice on synchronized method? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ThrowsAdvice on synchronized method?

    What are the semantics of a ThrowsAdvice for a synchronized method? Do I need to synchronize the advice methods? Is that enough -- ie, Is the glue that spring uses to wrap the advised method synchronized? I guess this question applies to any aopalliance intercepter, no?

  • #2
    Spring does not synchronize in the AOP framework. Your target's synchronization will be unaffected if it uses synchronization--Spring is not changing its bytecodes. Does this answer your question?

    Comment


    • #3
      Originally posted by Rod Johnson
      ....Does this answer your question?
      Not really. I asking more about MethodInterceptor and the advise that it calls prior to the advised method.

      What I believe is: Since MethodInterceptor will invoke the advice prior the synced method they wrap, the advice is not part of the synchronized block.

      After thinking more on this, it seems obvious. Spring advice is allways aspectj calls-style, which also would have the same issue. Aspectj execution-style would (I think) be included inside the synhronized block. I just wanted to be clear what the requirements of advisor methods when they advise syncrhronized methods.

      (Am I making any sense?)

      Comment


      • #4
        Barry

        What I believe is: Since MethodInterceptor will invoke the advice prior the synced method they wrap, the advice is not part of the synchronized block.
        That is correct. If you want to synchronize the advice on the target instance you could synchronize on MethodInvocation.getThis.

        Or you could address the threadsafety issue with a pooling TargetSource.

        Rgds
        Rod

        Comment

        Working...
        X