Skip to content

NullPointerException can happen in HttpRequestMethodNotSupportedException.getSupportedHttpMethods() [SPR-15377] #19941

@spring-projects-issues

Description

@spring-projects-issues

Istvan Ratkai opened SPR-15377 and commented

You can create an object without supportedMethod array.
public HttpRequestMethodNotSupportedException(String method) {
this(method, (String[]) null);
}

However when getSupportedHttpMethods() is called there is no null-check for this.supportedMethods in it:

public Set<HttpMethod> getSupportedHttpMethods() {
	List<HttpMethod> supportedMethods = new LinkedList<HttpMethod>();
	for (String value : this.supportedMethods) {
		HttpMethod resolved = HttpMethod.resolve(value);
		if (resolved != null) {
			supportedMethods.add(resolved);
		}
	}
	return EnumSet.copyOf(supportedMethods);
}

Affects: 4.3.7

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions