-
Notifications
You must be signed in to change notification settings - Fork 27
Debugging Windows file locking
Nadine Quin edited this page May 17, 2022
·
1 revision
The main source of all Windows locking problems are unclosed AutoCloseable
subclasses.
This includes, but is not limited to, incorrect usage of:
Files.newInputStream
Files.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
pid
while grepping for the port:ps -cdef | grep 'address=5005'
-
Generalise that to a
watch
task:watch -n 1 ls -l /proc/$(ps -cdef | grep 'address=5005' | head -1 | awk '{print$2}')/fd \| grep junit
-
grep
it for files injunit
folders.You can now run the integration (or unit tests if you omit
5005
) and step through watching when file descriptors appear.