Skip to content

Commit 2726072

Browse files
committed
Catch if writeToWatchLog tries to write to a closed file.
1 parent 14b94ef commit 2726072

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

runner/daemon/src/mill/daemon/Watching.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import mill.define.{PathRef, WorkspaceRoot}
77
import mill.internal.Colors
88

99
import java.io.InputStream
10+
import java.nio.channels.ClosedChannelException
1011
import scala.annotation.tailrec
1112
import scala.util.Using
1213

@@ -124,8 +125,12 @@ object Watching {
124125
def doWatchFsNotify() = {
125126
Using.resource(os.write.outputStream(watchArgs.serverDir / "fsNotifyWatchLog")) { watchLog =>
126127
def writeToWatchLog(s: String): Unit = {
127-
watchLog.write(s.getBytes(java.nio.charset.StandardCharsets.UTF_8))
128-
watchLog.write('\n')
128+
try {
129+
watchLog.write(s.getBytes(java.nio.charset.StandardCharsets.UTF_8))
130+
watchLog.write('\n')
131+
} catch {
132+
case _: ClosedChannelException => /* do nothing, the file is already closed */
133+
}
129134
}
130135

131136
@volatile var pathChangesDetected = false

0 commit comments

Comments
 (0)