Community
Participate
Working Groups
In bug 336227 I'm trying to be a good citizen and clean up after running tests. The problem I found is that I'm not able to delete directories with clones as long as tests are running. This boils down to a pack file that cannot be removed. I've modified org.eclipse.jgit.api.CloneCommandTest to illustrate the issue I'm dealing with. I'm not sure if this is something I should upload to Gerrit. This is not a real patch.
Created attachment 188677 [details] failing tests
In JGit, we wrote a FileUtils class to help with this... FileUtils.delete(repo.getWorkTree(), FileUtils.RECURSIVE | FileUtils.RETRY); org.eclipse.jgit.util.FileUtils Try that first, if it doesn't work, then we can dig deeper.
Created attachment 188693 [details] failing test with org.eclipse.jgit.util.FileUtils Thanks for the tip but it didn't help. I still get: "java.lang.AssertionError: Could not delete file C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\testCloneRepository3656357236185082524664761946001\.git\objects\pack\pack-5a1e97de671900849c0b7657ff9e866080544d28.pack [...]"
Created attachment 188694 [details] mylyn/context/zip
You are creating a new Git object that has a repository associated with it. This repository is automatically opened and thus has to be closed so that file resources are released. By adding "git2.getRepository().close();" before "FileUtils.delete(...);", the repository gets closed, the pack file is released and removing the directory works. I think contributing this enhanced test case would be a good idea.