mirror of https://github.com/sbt/sbt.git
Merge pull request #5728 from eatkins/observer-memory-leak
Close file tree repository registrations
This commit is contained in:
commit
9beecf98e0
|
|
@ -178,7 +178,7 @@ private[sbt] object Continuous extends DeprecatedContinuous {
|
||||||
val repository = getRepository(state)
|
val repository = getRepository(state)
|
||||||
dynamicInputs ++= inputs
|
dynamicInputs ++= inputs
|
||||||
logger.debug(s"[watch] [${scopedKey.show}] Found inputs: ${inputs.map(_.glob).mkString(",")}")
|
logger.debug(s"[watch] [${scopedKey.show}] Found inputs: ${inputs.map(_.glob).mkString(",")}")
|
||||||
inputs.foreach(i => repository.register(i.glob))
|
inputs.foreach(i => repository.register(i.glob).foreach(_.close()))
|
||||||
val watchSettings = new WatchSettings(scopedKey)
|
val watchSettings = new WatchSettings(scopedKey)
|
||||||
new Config(
|
new Config(
|
||||||
scopedKey.show,
|
scopedKey.show,
|
||||||
|
|
@ -462,7 +462,7 @@ private[sbt] object Continuous extends DeprecatedContinuous {
|
||||||
if (trackMetaBuild) {
|
if (trackMetaBuild) {
|
||||||
state.get(CheckBuildSources.CheckBuildSourcesKey).flatMap(_.fileTreeRepository) match {
|
state.get(CheckBuildSources.CheckBuildSourcesKey).flatMap(_.fileTreeRepository) match {
|
||||||
case Some(r) => buildGlobs.foreach(r.register(_).foreach(observers.addObservable))
|
case Some(r) => buildGlobs.foreach(r.register(_).foreach(observers.addObservable))
|
||||||
case _ => buildGlobs.foreach(repo.register)
|
case _ => buildGlobs.foreach(repo.register(_).foreach(_.close()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,6 +505,7 @@ private[sbt] object Continuous extends DeprecatedContinuous {
|
||||||
override def close(): Unit = {
|
override def close(): Unit = {
|
||||||
configHandle.close()
|
configHandle.close()
|
||||||
handles.forEach(_.close())
|
handles.forEach(_.close())
|
||||||
|
observers.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val watchLogger: WatchLogger = msg => logger.debug(msg.toString)
|
val watchLogger: WatchLogger = msg => logger.debug(msg.toString)
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,13 @@ private[sbt] class CheckBuildSources extends AutoCloseable {
|
||||||
val repo = FileTreeRepository.default
|
val repo = FileTreeRepository.default
|
||||||
repo.addObserver(_ => needUpdate.set(true))
|
repo.addObserver(_ => needUpdate.set(true))
|
||||||
repository.set(repo)
|
repository.set(repo)
|
||||||
newSources.foreach(g => repo.register(g))
|
newSources.foreach(g => repo.register(g).foreach(_.close()))
|
||||||
case r =>
|
case r =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val previousSources = sources.getAndSet(newSources)
|
val previousSources = sources.getAndSet(newSources)
|
||||||
if (previousSources != newSources) {
|
if (previousSources != newSources) {
|
||||||
fileTreeRepository.foreach(r => newSources.foreach(g => r.register(g)))
|
fileTreeRepository.foreach(r => newSources.foreach(g => r.register(g).foreach(_.close())))
|
||||||
previousStamps.set(getStamps(force = true))
|
previousStamps.set(getStamps(force = true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ private[sbt] object Settings {
|
||||||
// This makes watch work by ensuring that the input glob is registered with the
|
// This makes watch work by ensuring that the input glob is registered with the
|
||||||
// repository used by the watch process.
|
// repository used by the watch process.
|
||||||
state.value.get(globalFileTreeRepository).foreach { repo =>
|
state.value.get(globalFileTreeRepository).foreach { repo =>
|
||||||
inputs.foreach(repo.register)
|
inputs.foreach(repo.register(_).foreach(_.close()))
|
||||||
}
|
}
|
||||||
dynamicInputs.foreach(_ ++= inputs.map(g => DynamicInput(g, stamper, forceTrigger)))
|
dynamicInputs.foreach(_ ++= inputs.map(g => DynamicInput(g, stamper, forceTrigger)))
|
||||||
view.list(inputs)
|
view.list(inputs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue