Closed nivertius closed 6 years ago
Hi @nivertius,
Thanks for the patch!
I think, however, that the decision if send should be synchronized or not should not depend on configuration value. I'd rather process the following way:
Extend WebsocketIOServlet
- to return SynchronizedWebsocketTransportProvider
.
SynchronizedWebsocketTransportProvider
- returns SynchronizedWebsocketTransport
.
SynchronizedWebsocketTransport
- returns SynchronizedWebsocketTransportConnection
SynchronizedWebsocketTransportConnection
- wrap there calls of super.sendXXX
into synchronized
block
WDYT?
Hello @alexsaveliev,
Thanks for quick response.
Actually, we tried that before forking. :smiley:
WebsocketTransportConnection
is a final class, and for a reason: it has ServerEndpoint
annotation, and is actually created by application container. We've tried overriding configuration, but that didn't help either.
This was, IOHO, the best way to solve this, but we are open for suggestions.
Let's make it synchronized
then?
Synchronize methods sendXXX
in WebsocketTransportConnection
without possibility of configuration?
This might not be exactly the solution everybody wants, because if they have some kind of external synchronization, or thier buisness logic assures that multiple messages won't be sent at once, this synchronization is redundant or unnecessary.
How about cfdc1c157ea2340d87d1e25a6cf6d96d20241b5f? If you are fine with it, I'll merge my changes to master and then we'll bump artifact
This solves our problem, but I'm still in favor of configuration in servlet parameters instead of static field. I'll rebase @tomasztomasztomasz commit with your changes in a minute.
After second thought, your solution is fine, when you are doing jar scanning for servlets.
We would be grateful, if you'd merge cfdc1c1 and release new version to central.
1.0.6 should be in maven central now, please test
Depending on this parameter websocket transport "send" methods are either wrapped synchronized block or not. Change was made due to invalid socket state exception (FULL_TEXT_WRITING) on simultaneously emitted messages via same websocket instance.