Skip to content

NPE if StompEndpointRegistry has allowedOrigins with null #26987

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

Closed
manderson23 opened this issue May 27, 2021 · 1 comment
Closed

NPE if StompEndpointRegistry has allowedOrigins with null #26987

manderson23 opened this issue May 27, 2021 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Milestone

Comments

@manderson23
Copy link

The following code with 5.3.6 ran OK when properties.getAllowedOrigins() returned null.

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) 
{
  registry.addEndpoint(properties.getEndpoint())
             .setAllowedOrigins(properties.getAllowedOrigins())
             .withSockJS();
}

With 5.3.7 we get a NPE

Caused by: java.lang.NullPointerException
	at org.springframework.web.cors.CorsConfiguration.trimTrailingSlash(CorsConfiguration.java:146)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1654)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.springframework.web.cors.CorsConfiguration.setAllowedOrigins(CorsConfiguration.java:142)
	at org.springframework.web.socket.server.support.OriginHandshakeInterceptor.setAllowedOrigins(OriginHandshakeInterceptor.java:91)
	at org.springframework.web.socket.server.support.OriginHandshakeInterceptor.<init>(OriginHandshakeInterceptor.java:65)
	at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration.getInterceptors(WebMvcStompWebSocketEndpointRegistration.java:135)
	at org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration.withSockJS(WebMvcStompWebSocketEndpointRegistration.java:115)
	at com.ge.lfc.ui.backend.data.websocket.WebSocketConfiguration.registerStompEndpoints(WebSocketConfiguration.java:48)
	at org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration.registerStompEndpoints(DelegatingWebSocketMessageBrokerConfiguration.java:60)
	at org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport.stompWebSocketHandlerMapping(WebSocketMessageBrokerConfigurationSupport.java:91)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label May 27, 2021
@rstoyanchev rstoyanchev self-assigned this Jun 2, 2021
@rstoyanchev rstoyanchev added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jun 2, 2021
@rstoyanchev rstoyanchev added this to the 5.3.8 milestone Jun 2, 2021
@rstoyanchev
Copy link
Contributor

I presume you mean that the list contains null elements or at least that's what I gather from the stacktrace but you can give 5.3.8-SNAPSHOT a try.

@rstoyanchev rstoyanchev changed the title NPE if StompEndpointRegistry has AllowedOrigins set to null NPE if StompEndpointRegistry has allowedOrigins with null Jun 2, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this issue Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

3 participants