Skip to content

Commit

Permalink
fix: OverlappingFileLockException
Browse files Browse the repository at this point in the history
  • Loading branch information
warnyul committed Aug 14, 2024
1 parent 695ddf2 commit c6c5baa
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import java.nio.channels.FileLock
import java.nio.channels.OverlappingFileLockException
import java.util.concurrent.ExecutorService


internal class JUnit5MavenDependencyResolver private constructor(
repositoryUrl: String,
repositoryId: String,
Expand Down Expand Up @@ -82,11 +81,12 @@ internal class JUnit5MavenDependencyResolver private constructor(
raf.channel.use { channel ->
var lock: FileLock? = null
while (lock == null) {
@Suppress("SwallowedException")
try {
lock = channel.tryLock()
} catch (e: OverlappingFileLockException) {
// Sleep for a while before retrying
Thread.sleep(100)
Thread.sleep(WAIT_MS_UNTIL_LOCK_FILE_RELEASED)
}
}
runnable.run()
Expand All @@ -101,6 +101,7 @@ internal class JUnit5MavenDependencyResolver private constructor(
}

private companion object {
private const val WAIT_MS_UNTIL_LOCK_FILE_RELEASED = 100L
private const val SPECIAL_CHARACTERS_IN_FILE_NAME_REGEX = """[<>:"\\/|\?\*]"""
}
}

0 comments on commit c6c5baa

Please sign in to comment.