Skip to content

Add null checks to constructors #6892

Closed
@jzheaux

Description

@jzheaux

Related to #6542

RequestKey, JaasGrantedAuthority, and SwitchUserGrantedAuthority each anticipate certain final members will be non-null without requiring such in the constructor.

For example, RequestKey does the following in equals:

if (!url.equals(key.url)) {
    return false;
}

Where url is a member variable. But, the constructor does nothing to ensure this behavior will actually work:

public RequestKey(String url, String method) {
    this.url = url;
    this.method = method;
}

For RequestKey, we should change the constructor to something like:

public RequestKey(String url, String method) {
    Assert.notNull(url, "url cannot be null");
    this.url = url;
    this.method = method;
}

And we'd do similar things for the other two classes.

Metadata

Metadata

Assignees

Labels

in: coreAn issue in spring-security-coretype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions