Skip to content

getSockJsPath() method in org.springframework.web.socket.sockjs.support.AbstractSockJsService returns wrong path [SPR-10923] #15551

@spring-projects-issues

Description

@spring-projects-issues

Ralph Schaer opened SPR-10923 and commented

Tested with version: spring-websocket-4.0.0.BUILD-20130914.053543-227

The method getSockJsPath() in the class org.springframework.web.socket.sockjs.support.AbstractSockJsService creates a wrong result in the following scenario:

DispatcherServlet mapped to /snakedemo/*

public class DispatcherServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
...

	@Override
	protected String[] getServletMappings() {
		return new String[] { "/snakedemo/*" };
	}
...
}

Websocket/SockJS Handler mapped to /snake

@Configuration
@EnableWebMvc
@EnableWebSocket
public class WebConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(snakeWebSocketHandler(), "/snake").withSockJS();
	}
...
}

The client then tries to send a GET request to info and the server returns a 404. The problem is the code in getSockJsPath line 362-371 that results in a wrong sockjs path

request.getURI().getPath() ==> /snakedemo/snake/info
Return value of getSockJsPath() ==> demo/snake/info

Affects: 4.0 M3

Referenced from: commits e60e8dc

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