-
Couldn't load subscription status.
- Fork 27
Debugging Windows file locking
The main source of all Windows locking problems are unclosed AutoCloseable subclasses.
This includes, but is not limited to, incorrect usage of:
Files.newInputStreamFiles.list(...)
Ensure that these use the .use { } scope function or our Path.list(block: (Stream<Path>) -> R) extension function.
To find any files opened by Linux, where the file descriptor was not released, run this command:
ls -l /proc/<pid>/fd
If you are debugging an integration test, to retrieve the file descriptors:
-
Find the
pidwhile grepping for the port:ps -cdef | grep 'address=5005' -
Generalise that to a
watchtask:watch -n 1 ls -l /proc/$(ps -cdef | grep 'address=5005' | head -1 | awk '{print$2}')/fd \| grep junit -
grepit for files injunitfolders.You can now run the integration (or unit tests if you omit
5005) and step through watching when file descriptors appear.