From b637db445e5d1fef6c0d3e6585327a73d7da076a Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 1 Dec 2017 12:48:56 +0000 Subject: [PATCH 1/2] Really make "should detect modified files" pending I don't understand how you're meant to do pendingUntilFixed in ScalaTest, like specs2.. --- .../scala/sbt/internal/io/SourceModificationWatchSpec.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala b/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala index 5d0b37e7..6669533b 100644 --- a/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala +++ b/io/src/test/scala/sbt/internal/io/SourceModificationWatchSpec.scala @@ -21,9 +21,9 @@ abstract class SourceModificationWatchSpec( IO.write(file, "foo") - watchTest(parentDir)(pollDelay, maxWait) { - IO.write(file, "bar") - } + // watchTest(parentDir)(pollDelay, maxWait) { + // IO.write(file, "bar") + // } pending // until fixed https://github.com/sbt/io/issues/82 } From 5c0db3b3fbea2b9fc37f7d320c65dd3ecfe0f437 Mon Sep 17 00:00:00 2001 From: Ivan Poliakov Date: Wed, 29 Nov 2017 13:40:13 +0000 Subject: [PATCH 2/2] Prevent concurrent modification of keysWithEvents map Fixes #86 which means Fixes sbt/sbt#3687 Fixes sbt/sbt#3695 Fixes sbt/sbt#3775 --- build.sbt | 9 +++++++-- io/src/main/scala/sbt/io/PollingWatchService.scala | 6 ++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/build.sbt b/build.sbt index 7dab22d1..583aaf87 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ import Dependencies._ -// import com.typesafe.tools.mima.core._, ProblemFilters._ +import com.typesafe.tools.mima.core._, ProblemFilters._ def baseVersion: String = "1.1.0" @@ -36,5 +36,10 @@ val io = (project in file("io")) libraryDependencies ++= Seq(scalaCompiler.value % Test, scalaCheck % Test, scalatest % Test), sourceManaged in (Compile, generateContrabands) := baseDirectory.value / "src" / "main" / "contraband-scala", initialCommands in console += "\nimport sbt.io._, syntax._", - mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "1.0.0") + mimaPreviousArtifacts := Set(organization.value %% moduleName.value % "1.0.0"), + mimaBinaryIssueFilters ++= Seq( + // MiMa doesn't understand private inner classes? + // method this(sbt.io.PollingWatchService,sbt.io.PollingWatchService#PollingThread,java.nio.file.Watchable,java.util.List)Unit in class sbt.io.PollingWatchService#PollingWatchKey does not have a correspondent in current version + exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingWatchKey.this"), + ), ) diff --git a/io/src/main/scala/sbt/io/PollingWatchService.scala b/io/src/main/scala/sbt/io/PollingWatchService.scala index 90da27bc..37dfb9f1 100644 --- a/io/src/main/scala/sbt/io/PollingWatchService.scala +++ b/io/src/main/scala/sbt/io/PollingWatchService.scala @@ -67,7 +67,7 @@ class PollingWatchService(delay: FiniteDuration) extends WatchService { override def register(path: JPath, events: WatchEvent.Kind[JPath]*): WatchKey = { ensureNotClosed() - val key = new PollingWatchKey(thread, path, new java.util.ArrayList[WatchEvent[_]]) + val key = new PollingWatchKey(path, new java.util.ArrayList[WatchEvent[_]]) keys += path -> key watched += path -> events key @@ -158,14 +158,12 @@ class PollingWatchService(delay: FiniteDuration) extends WatchService { } private class PollingWatchKey( - origin: PollingThread, override val watchable: Watchable, val events: JList[WatchEvent[_]] ) extends WatchKey { override def cancel(): Unit = () override def isValid(): Boolean = true - override def pollEvents(): java.util.List[WatchEvent[_]] = origin.keysWithEvents.synchronized { - origin.keysWithEvents -= this + override def pollEvents(): java.util.List[WatchEvent[_]] = { val evs = new java.util.ArrayList[WatchEvent[_]](events) events.clear() evs