mirror of https://github.com/sbt/sbt.git
We have seen failures in scripted to create the output file for streams and it has also been reported in https://github.com/sbt/sbt/issues/5067. I believe this may caused by the same stream output being initialized by multiple tasks. To fix this, I add locking on a per-file basis. There was (and is) additional synchronization on the Streams _instance_, but the per-file locks are stored in the Streams companion object so the locking should be honored no matter which Streams instance calls make. I also skip the call to IO.touch if the file already exists. I believe that this is the common case and since IO.touch was being called with setModified = false, it should be fine to skip the touch when the file exists. Prior to this change, I was able to induce the issue in #5067 in roughly 1/50 of calls to `scripted actions/cross-multiproject`. I wasn't able to reproduce after this change. |
||
|---|---|---|
| .. | ||
| src | ||
| NOTICE | ||