You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ma...@apache.org on 2026/04/21 14:32:39 UTC
(grails-spring-security) branch grails8-sb4 updated: fix: simplify `DefaultRestAuthenticatorEventPublisher` construction
This is an automated email from the ASF dual-hosted git repository.
matrei pushed a commit to branch grails8-sb4
in repository https://gitbox.apache.org/repos/asf/grails-spring-security.git
The following commit(s) were added to refs/heads/grails8-sb4 by this push:
new af8385989 fix: simplify `DefaultRestAuthenticatorEventPublisher` construction
af8385989 is described below
commit af8385989d8b66b0c84113d525522ebe66ffedbe
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Tue Apr 21 16:32:21 2026 +0200
fix: simplify `DefaultRestAuthenticatorEventPublisher` construction
Parent `DefaultAuthenticationEventPublisher` creates its own
no-op publisher when constructed without arguments.
---
.../DefaultRestAuthenticationEventPublisher.groovy | 13 ++-----------
.../DefaultRestAuthenticationEventPublisherSpec.groovy | 9 ---------
2 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/plugin-rest/spring-security-rest/src/main/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisher.groovy b/plugin-rest/spring-security-rest/src/main/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisher.groovy
index 42ec6c951..952842156 100644
--- a/plugin-rest/spring-security-rest/src/main/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisher.groovy
+++ b/plugin-rest/spring-security-rest/src/main/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisher.groovy
@@ -30,23 +30,14 @@ import org.springframework.security.authentication.DefaultAuthenticationEventPub
@CompileStatic
class DefaultRestAuthenticationEventPublisher extends DefaultAuthenticationEventPublisher implements RestAuthenticationEventPublisher {
- // Spring Security 7 no longer accepts a null ApplicationEventPublisher in the
- // DefaultAuthenticationEventPublisher constructor, so use a no-op fallback until
- // Spring injects the real publisher through the setter.
- private static final ApplicationEventPublisher NO_OP_APPLICATION_EVENT_PUBLISHER = new ApplicationEventPublisher() {
- @Override
- void publishEvent(Object event) {
- }
- }
-
private ApplicationEventPublisher applicationEventPublisher
DefaultRestAuthenticationEventPublisher() {
- this(null)
+ super()
}
DefaultRestAuthenticationEventPublisher(ApplicationEventPublisher publisher) {
- super(publisher ?: NO_OP_APPLICATION_EVENT_PUBLISHER)
+ super(publisher)
this.applicationEventPublisher = publisher
}
diff --git a/plugin-rest/spring-security-rest/src/test/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisherSpec.groovy b/plugin-rest/spring-security-rest/src/test/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisherSpec.groovy
index 68c52e9b9..343679a96 100644
--- a/plugin-rest/spring-security-rest/src/test/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisherSpec.groovy
+++ b/plugin-rest/spring-security-rest/src/test/groovy/grails/plugin/springsecurity/rest/authentication/DefaultRestAuthenticationEventPublisherSpec.groovy
@@ -83,15 +83,6 @@ class DefaultRestAuthenticationEventPublisherSpec extends Specification {
0 * eventPublisher.publishEvent(_)
}
- void "should allow null publisher in constructor and remain no-op for token events"() {
- when:
- new DefaultRestAuthenticationEventPublisher(null).publishTokenCreation(accessToken)
-
- then:
- noExceptionThrown()
- 0 * eventPublisher.publishEvent(_)
- }
-
void "should not execute parent publishEvent when publisher is not set"() {
when:
new DefaultRestAuthenticationEventPublisher().publishAuthenticationSuccess(accessToken)