From 46724159daa3501529b552e940ec43177dc1398d Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Wed, 29 Jul 2020 16:06:43 -0700 Subject: [PATCH] Stop filling json codec cache These were not actually used as far as I could tell. The json codecs cache showed up as taking up 30MB in a heap dump that I took after running compile 30 times in a clone of the repro project in https://github.com/sbt/sbt/issues/5508. --- .../src/main/scala/sbt/util/LogExchange.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala b/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala index 326d23d3c..90e6cc39f 100644 --- a/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala +++ b/internal/util-logging/src/main/scala/sbt/util/LogExchange.scala @@ -24,7 +24,6 @@ sealed abstract class LogExchange { private[sbt] lazy val context: LoggerContext = init() private[sbt] lazy val builtInStringCodecs: Unit = initStringCodecs() private[sbt] lazy val asyncStdout: AsyncAppender = buildAsyncStdout - private[sbt] val jsonCodecs: concurrent.Map[String, JsonFormat[_]] = concurrent.TrieMap() private[sbt] val stringCodecs: concurrent.Map[String, ShowLines[_]] = concurrent.TrieMap() def logger(name: String): ManagedLogger = logger(name, None, None) @@ -100,12 +99,15 @@ sealed abstract class LogExchange { lo } - def jsonCodec[A](tag: String): Option[JsonFormat[A]] = - jsonCodecs.get(tag) map { _.asInstanceOf[JsonFormat[A]] } - def hasJsonCodec(tag: String): Boolean = - jsonCodecs.contains(tag) - def getOrElseUpdateJsonCodec[A](tag: String, v: JsonFormat[A]): JsonFormat[A] = - jsonCodecs.getOrElseUpdate(tag, v).asInstanceOf[JsonFormat[A]] + @deprecated("It is now necessary to provide a json format instance", "1.4.0") + def jsonCodec[A](tag: String): Option[JsonFormat[A]] = None + @deprecated("Always returns false", "1.4.0") + def hasJsonCodec(tag: String): Boolean = false + @deprecated("This is a no-op", "1.4.0") + def getOrElseUpdateJsonCodec[A](tag: String, v: JsonFormat[A]): JsonFormat[A] = v + @deprecated("The log manager no longer caches jsonCodecs", "1.4.0") + def jsonCodecs(): concurrent.Map[String, JsonFormat[_]] = concurrent.TrieMap.empty + def stringCodec[A](tag: String): Option[ShowLines[A]] = stringCodecs.get(tag) map { _.asInstanceOf[ShowLines[A]] } def hasStringCodec(tag: String): Boolean =