Skip to content

SessionRepositoryFilter fails when bean proxied by Spring AOP #1658

Closed
@bboyz269

Description

@bboyz269

Describe the bug
I have a need to extends the SessionRepositoryFilter. The created bean is proxied by CGLIB, resulting all its private properties null. Causing NullPointerException in OncePerRequestFilter#doFilter

String alreadyFilteredAttributeName = this.alreadyFilteredAttributeName;
boolean hasAlreadyFilteredAttribute = request.getAttribute(alreadyFilteredAttributeName) != null;

To Reproduce
Create a bean that extends SessionRepositoryFilter with CGLIB proxying enabled.

@Bean(AbstractHttpSessionApplicationInitializer.DEFAULT_FILTER_NAME)
@Order(SessionRepositoryFilter.DEFAULT_ORDER)
public <S extends Session> MyCustomSessionRepositoryFilter sessionRepositoryFilter(...) {
    return new MyCustomSessionRepositoryFilter(...);
}

proxied-by-cglib

Expected behavior
The custom session repository filter should work properly without any exceptions (NullPointerException)

Sample
I created a pull request here
#1657

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions