code review

This commit is contained in:
Adrien Piquerez 2020-05-12 17:40:16 +02:00
parent 42e4c5a7c0
commit c221f57812
1 changed files with 6 additions and 6 deletions

View File

@ -56,7 +56,7 @@ final class NetworkChannel(
private val VsCode = sbt.protocol.Serialization.VsCode private val VsCode = sbt.protocol.Serialization.VsCode
private val VsCodeOld = "application/vscode-jsonrpc; charset=utf8" private val VsCodeOld = "application/vscode-jsonrpc; charset=utf8"
private lazy val jsonFormat = new sjsonnew.BasicJsonProtocol with JValueFormats {} private lazy val jsonFormat = new sjsonnew.BasicJsonProtocol with JValueFormats {}
private val onGoingRequests: mutable.Set[String] = mutable.Set() private val pendingRequests: mutable.Map[String, JsonRpcRequestMessage] = mutable.Map()
def setContentType(ct: String): Unit = synchronized { _contentType = ct } def setContentType(ct: String): Unit = synchronized { _contentType = ct }
def contentType: String = _contentType def contentType: String = _contentType
@ -258,7 +258,7 @@ final class NetworkChannel(
private def registerRequest(request: JsonRpcRequestMessage): Unit = { private def registerRequest(request: JsonRpcRequestMessage): Unit = {
this.synchronized { this.synchronized {
onGoingRequests += request.id pendingRequests += (request.id -> request)
() ()
} }
} }
@ -268,8 +268,8 @@ final class NetworkChannel(
execId: Option[String] execId: Option[String]
): Unit = this.synchronized { ): Unit = this.synchronized {
execId match { execId match {
case Some(id) if onGoingRequests.contains(id) => case Some(id) if pendingRequests.contains(id) =>
onGoingRequests -= id pendingRequests -= id
jsonRpcRespondError(id, err) jsonRpcRespondError(id, err)
case _ => case _ =>
logMessage("error", s"Error ${err.code}: ${err.message}") logMessage("error", s"Error ${err.code}: ${err.message}")
@ -289,8 +289,8 @@ final class NetworkChannel(
execId: Option[String] execId: Option[String]
): Unit = this.synchronized { ): Unit = this.synchronized {
execId match { execId match {
case Some(id) if onGoingRequests.contains(id) => case Some(id) if pendingRequests.contains(id) =>
onGoingRequests -= id pendingRequests -= id
jsonRpcRespond(event, id) jsonRpcRespond(event, id)
case _ => case _ =>
log.debug( log.debug(