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

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

Closed
spring-issuemaster opened this Issue Mar 23, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Mar 23, 2017

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

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Mar 23, 2017

Juergen Hoeller commented

I've clarified and revised the null handling for both getSupportedMethods and getSupportedHttpMethods, as well as the corresponding constructors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.