NullPointerException in ProxyExchangeArgumentResolver
See original GitHub issueDescribe the bug
I have a proxy gateway setup very similar to the one in the documentation. https://cloud.spring.io/spring-cloud-gateway/reference/html/#building-a-simple-gateway-by-using-spring-mvc-or-webflux
In version 2.2.1 everything works fine. In version 2.2.2 there following error occurs:
Caused by: java.lang.NullPointerException: null
at org.springframework.cloud.gateway.mvc.config.ProxyExchangeArgumentResolver.resolveArgument(ProxyExchangeArgumentResolver.java:81)
Every version since 2.2.2 results in the same error. I believe this will happen whenever org.springframework.cloud.gateway.mvc.config.ProxyExchangeArgumentResolver::autoForwardedHeaders is null. https://github.com/spring-cloud/spring-cloud-gateway/blob/d2ea0ebd822b71c70a6e1bb4bfc7bf73423ac051/spring-cloud-gateway-mvc/src/main/java/org/springframework/cloud/gateway/mvc/config/ProxyExchangeArgumentResolver.java#L48
Sample
I don’t have a sample, but it should be pretty easy to prove with a unit test and the code problem seems obvious (although I have very little experience looking at spring source code).
Code indicating autoForwardedHeaders can be null:
public void setAutoForwardedHeaders(Set<String> autoForwardedHeaders) {
this.autoForwardedHeaders = autoForwardedHeaders == null ? null
: autoForwardedHeaders.stream().map(String::toLowerCase).collect(toSet());
}
Code where there’s no null check:
if (this.autoForwardedHeaders.size() > 0) {
proxy.headers(extractAutoForwardedHeaders(webRequest));
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Hi @spencergibb I’ve created the following PR #2163 which solves the issue. I hope that all is ok, if not, let me know and I’d try to solve asap. Thanks!
Great. Let me know if you need some help