Skip to content

Unnecessary proxying with MethodMapTransactionAttributeSource [SPR-16733] #21274

Closed

Description

@spring-projects-issues

Rob Winch opened SPR-16733 and commented

The changes for in b5922f75 means that now unnecessary objects are proxied.

MethodMapTransactionAttributeSource now uses now uses ReflectionUtils.getAllDeclaredMethods which means that when something like addTransactionalMethod("sample.Foo.*", ...) is invoked, all the methods (including the methods on Object) are added to the transactionAttributeMap.

Then when a method from Object is queried on any class (i.e. MethodMapTransactionAttributeSource.getTransactionAttribute(finalizeMethod,JdbcTemplate.class)) the result is true, so every object ends up getting proxied.

A complete example of the issue can be seen at https://github.com/rwinch/spring-aop-proxy-issue/blob/master/src/test/java/sample/ProxyTests.java


Affects: 5.0.6

Issue Links:

Activity

  1. spring-projects-issues commented on Apr 17, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Good point, this was just meant as a convenience for interface refactorings where methods happened to move to a super-interface. I'm afraid I forgot to consider ".*" patterns...

    I'll simply revert to the previous implementation then and adapt the corresponding test case to explicitly refer to the super-interface. Whenever extracting a parent interface, people will simply have to adapt their method pattern the same way (as before).

  2. spring-projects-issues commented on Apr 18, 2018

    @spring-projects-issues
    CollaboratorAuthor

    Rob Winch commented

    Thanks for the fast turnaround. I can confirm that the latest SNAPSHOTs have fixed the issue.

  3. added
    type: regression
    in: core
    on Jan 11, 2019
  4. added this to the 5.0.6 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions