mirror of https://github.com/sbt/sbt.git
Merge pull request #8282 from eed3si9n/wip/gson
[2.x] fix: Catch gson parsing error
This commit is contained in:
commit
8193d6befb
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import com.google.gson.{ JsonObject, JsonParser }
|
import com.google.gson.{ JsonObject, JsonParser, JsonSyntaxException }
|
||||||
import testing.{ Logger as _, Task as _, * }
|
import testing.{ Logger as _, Task as _, * }
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
@ -25,6 +25,7 @@ import scala.collection.mutable
|
||||||
import scala.concurrent.{ Await, Promise }
|
import scala.concurrent.{ Await, Promise }
|
||||||
import scala.concurrent.duration.Duration
|
import scala.concurrent.duration.Duration
|
||||||
import scala.util.Random
|
import scala.util.Random
|
||||||
|
import scala.util.control.NonFatal
|
||||||
import scala.jdk.CollectionConverters.*
|
import scala.jdk.CollectionConverters.*
|
||||||
import scala.sys.process.Process
|
import scala.sys.process.Process
|
||||||
|
|
||||||
|
|
@ -186,17 +187,20 @@ private class React(
|
||||||
val g = WorkerMain.mkGson()
|
val g = WorkerMain.mkGson()
|
||||||
val promise: Promise[Int] = Promise()
|
val promise: Promise[Int] = Promise()
|
||||||
override def apply(line: String): Unit =
|
override def apply(line: String): Unit =
|
||||||
// scala.Console.err.println(line)
|
try
|
||||||
val o = JsonParser.parseString(line).getAsJsonObject()
|
val o = JsonParser.parseString(line).getAsJsonObject()
|
||||||
if o.has("id") then
|
if o.has("id") then
|
||||||
val resId = o.getAsJsonPrimitive("id").getAsLong()
|
val resId = o.getAsJsonPrimitive("id").getAsLong()
|
||||||
if resId == id then
|
if resId == id then
|
||||||
if promise.isCompleted then ()
|
if promise.isCompleted then ()
|
||||||
else if o.has("error") then promise.failure(new RuntimeException(line))
|
else if o.has("error") then promise.failure(new RuntimeException(line))
|
||||||
else promise.success(0)
|
else promise.success(0)
|
||||||
|
else ()
|
||||||
|
else if o.has("method") then processNotification(o)
|
||||||
else ()
|
else ()
|
||||||
else if o.has("method") then processNotification(o)
|
catch
|
||||||
else ()
|
case _: JsonSyntaxException => log.info(line)
|
||||||
|
case NonFatal(_) => ()
|
||||||
|
|
||||||
override def notifyExit(p: Process): Unit =
|
override def notifyExit(p: Process): Unit =
|
||||||
if !process.isAlive then promise.success(process.exitValue())
|
if !process.isAlive then promise.success(process.exitValue())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue