Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Files remaining locked after repository close in Windows
Files remaining locked after repository close in Windows [message #1814611] Fri, 13 September 2019 20:32 Go to next message
Nathan Jent is currently offline Nathan JentFriend
Messages: 2
Registered: September 2019
Junior Member
I have unit tests that delete the local repository after running. This works okay until I started using the RevWalk to get the HEAD commit for the repository. I'm using this example as a starting point.
// this seems to be the offending line
RevCommit commit = revWalk.parseCommit(lastCommitId);

The code works for a unit test that only calls the readFile method once but fails to delete when cleaning up the unit test that accesses a list of files. I have attempted the FileUtils resolution from this issue, but that was unsuccessful.
Re: Files remaining locked after repository close in Windows [message #1814702 is a reply to message #1814611] Mon, 16 September 2019 20:35 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1106
Registered: July 2009
Senior Member
Create the RevWalk in a try with resource in order to ensure it is closed at the end before the test teardown

try (RevWalk rw = new RevWalk(repo) {
// use the RevWalk to walk the version graph and parse objects
}
Re: Files remaining locked after repository close in Windows [message #1814760 is a reply to message #1814702] Tue, 17 September 2019 15:13 Go to previous message
Nathan Jent is currently offline Nathan JentFriend
Messages: 2
Registered: September 2019
Junior Member
Thanks. I figured out. I was trying to reuse the repository after it was closed in my code. Keeping it open for the entire scope fixed the issue.
Previous Topic:Git status very long since last release 5.4.2
Next Topic:Problems setting EGit with github
Goto Forum:
  


Current Time: Thu Dec 12 03:11:11 GMT 2019

Powered by FUDForum. Page generated in 0.01915 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top