Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secured event handler method invoked twice [DATAREST-582] #956

Closed
spring-projects-issues opened this issue Jun 17, 2015 · 1 comment
Closed
Assignees
Labels
type: bug A general bug

Comments

@spring-projects-issues
Copy link

Endre Czirbesz opened DATAREST-582 and commented

If I annotate my event handler methods with a Pre/Post annotation, it is added to the handlerMethods(…) twice, and as a consequence invoked twice.
I suppose this is not the intended behavior.

@Slf4j
@RepositoryEventHandler(User.class)
public class UserEventHandler {

    @HandleBeforeCreate
    @PreAuthorize("hasRole('ROLE_ADMIN'))
    public void handleNewUser(User newUser) {
        log.debug("Handle user {}", newUser);
       // processing here
    }
}

The two handlers in the map (package names removed) are

EventHandlerMethod{ 
    targetType=class User, 
    method=public final void  UserEventHandler$$EnhancerBySpringCGLIB$$a9872696.handleNewUser(User), 
    handler=UserEventHandler@77e9dca8 
}

and

EventHandlerMethod{ 
    targetType=class User, 
    method=public void UserEventHandler.handleNewUser(User), 
    handler=UserEventHandler@77e9dca8 
}

The EnhancerBySpringCGLIB version is not in the map when @PreAuthorize is removed


Affects: 2.3 GA (Fowler)

Backported to: 2.3.1 (Fowler SR1)

@spring-projects-issues
Copy link
Author

Oliver Drotbohm commented

This should be fixed. We now make sure we only inspect the user class for handler methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants