From bdafe367923e4772e7193d3c9a6767a95b0dd8af Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 23 Jul 2014 16:01:18 +0200 Subject: [PATCH] Try to recover after deleting opened files on NFS Fixes various LocalRepositoryTestCase based tests, which were failing if executed on NFS mount, see Bug 440182. The current workaround doesn't really checks for NFS (have no idea how to do this in Java) but allows tests running on "/home" to run "delete" cleanup twice (second "delete" round deletes unexpected nfs zombie files). The assumption is that this workaround should at least help *nix users with their NFS mounted home directories. Ideally the tests should be fixed to properly cleanup opened .pack file handles, but I've spent one day hunting the root cause on one single test without success, due the asynchronous nature of the resources creation/cleanup. Bug: 440182 Change-Id: I5e879daed954aa35de197d8e1ea43c9fbccca7d4 Signed-off-by: Andrey Loskutov --- .../org/eclipse/egit/ui/common/LocalRepositoryTestCase.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java index bd77fb072..b930b0b8a 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/LocalRepositoryTestCase.java @@ -236,6 +236,16 @@ public abstract class LocalRepositoryTestCase extends EGitTestCase { @AfterClass public static void afterClassBase() throws Exception { + File tempDir = testUtils.getBaseTempDir(); + if (tempDir.toString().startsWith("/home") && tempDir.exists()) { + // see bug 440182: if test has left opened file streams on NFS + // mounted directories "delete" will fail because the directory + // would contain "stolen NFS file handles" + // (something like .nfs* files) + // so the "first round" of delete can ignore failures. + FileUtils.delete(tempDir, FileUtils.IGNORE_ERRORS + | FileUtils.RECURSIVE | FileUtils.RETRY); + } testUtils.deleteTempDirs(); } -- 2.11.4.GIT