Synchronize ServerConnection.sendString

Without synchronization, it is possible to interlace liens from multiple
messages which causes parsing to fail on the server side.
This commit is contained in:
Ethan Atkins 2020-06-25 10:22:08 -07:00
parent ddc4e850b5
commit 4eedaea49e
1 changed files with 1 additions and 1 deletions

View File

@ -62,7 +62,7 @@ abstract class ServerConnection(connection: Socket) {
}
thread.start()
def sendString(message: String): Unit = {
def sendString(message: String): Unit = this.synchronized {
val a = message.getBytes("UTF-8")
writeLine(s"""Content-Length: ${a.length + 2}""".getBytes("UTF-8"))
writeLine(Array())