From f03320047e69f966e328435f48aafeb1c57029cc Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Mon, 25 Sep 2023 17:40:12 +0200 Subject: [PATCH] Keep logger names in hash set Previously, the list of logger names that have been created in a given context with Log4J was being kept in a `Vector`. As a result, subsequent calls to `logger` on a `Log4JLoggerContext` with the same logger name would introduce duplicates in the list. Note that Log4J's logger configuration would not allow duplicates, and only one configuration object for a given logger name will exist. The duplicates in the list of logger names are therefore unnecessary. With this patch, the logger names will be kept in a `HashSet`. Since the logger names are only used to remove the logger configurations after the logger context is closed, and the logger configurations contain no duplicates, removing duplicate logger names should not cause any issue. --- .../util-logging/src/main/scala/sbt/util/LoggerContext.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/util-logging/src/main/scala/sbt/util/LoggerContext.scala b/internal/util-logging/src/main/scala/sbt/util/LoggerContext.scala index c887c786f..58aa5107a 100644 --- a/internal/util-logging/src/main/scala/sbt/util/LoggerContext.scala +++ b/internal/util-logging/src/main/scala/sbt/util/LoggerContext.scala @@ -46,7 +46,7 @@ object LoggerContext { case a: AbstractConfiguration => a case _ => throw new IllegalStateException("") } - val loggers = new java.util.Vector[String] + val loggers = new java.util.HashSet[String] private[this] val closed = new AtomicBoolean(false) override def logger( name: String,