Skip to content

org.apache.tomcat.websocket.WsSession.requestUri can be null [SPR-15721] #20277

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
spring-projects-issues opened this issue Jun 30, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jun 30, 2017

Artem Bilan opened SPR-15721 and commented

The recent change to the StandardWebSocketSession via #20276, particularly the code:

@Override
public URI getUri() {
	Assert.state(this.uri != null, "WebSocket session is not yet initialized");
	return this.uri;
}

Produces the problem on the client side when we have, according org.apache.tomcat.websocket.WsSession JavaDocs:

* @param requestUri           The URI used to connect to this endpoint or
*                             <code>null</code> is this is a client session

Therefore that Assert has to be removed.

At the same time I'm not pretty sure how we may have it like:

@Nullable
private URI uri;

and say that it can't be null in the getUri().

Thanks


Affects: 5.0 RC3

Issue Links:

Referenced from: commits 9afce23

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

Indeed, previously that code was checking for the native session to be generally initialized, and now it checks for the uri field specifically. There is indeed a mismatch here: Since this implements the WebSocketSession.getUri() method there, we'll have to mark that method @Nullable at the interface level, matching the runtime invocation semantics.

As for the current mismatch between field and accessor, this is not so unusual: The uri field is initially not set (therefore nullable) and only populated on initializeNativeSession. From then onwards, the accessors expect non-null state, and the assertion just says "you called the accessor before initializing the native session". Now, for getUri() specifically, it may remain null even after the native session, which we need to fix as discussed above.

@spring-projects-issues
Copy link
Collaborator Author

Artem Bilan commented

Thanks, Juergen, for quick turnaround!

Works well now.

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: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants