Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit ListBranchCommand with contains does not close RevWalk
icon8.gif  JGit ListBranchCommand with contains does not close RevWalk [message #1699195] Mon, 22 June 2015 13:13 Go to next message
Michael Kuehn is currently offline Michael KuehnFriend
Messages: 1
Registered: June 2015
Junior Member
Hi,

i use JGit 4.0.0.4.0.0.201506090130-r to get all branches that contains a specified commit id. It works fine but the RevWalk in ListBranchCommand.filterRefs is never closed. So i can't delete the repository directory because some pack files are locked.

private Collection<Ref> filterRefs(Collection<Ref> refs)
  throws RefNotFoundException, IOException {
		if (containsCommitish == null)
			return refs;

		try (RevWalk walk = new RevWalk(repo)) {
			ObjectId resolved = repo.resolve(containsCommitish);
			if (resolved == null)
				throw new RefNotFoundException(MessageFormat.format(
						JGitText.get().refNotResolved, containsCommitish));

			RevCommit containsCommit = walk.parseCommit(resolved);
			return RevWalkUtils.findBranchesReachableFrom(containsCommit, walk,
					refs);
		}
	}


Can anyone help me to solve this issue? Thank you very much.
Michael
Re: JGit ListBranchCommand with contains does not close RevWalk [message #1699431 is a reply to message #1699195] Wed, 24 June 2015 09:50 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 274
Registered: July 2009
Senior Member
At least in the code snipped you provide the RevWalk itself get's closed when you leave the 'try() { }' block. RevWalk is autocloseable, so it's close method will be called before we exit the method. I guess that you forgot to close a Repository instance before you try to delete the filesystem content.

Ciao
Chris
Re: JGit ListBranchCommand with contains does not close RevWalk [message #1713209 is a reply to message #1699431] Mon, 02 November 2015 11:47 Go to previous message
Junyi Bei is currently offline Junyi BeiFriend
Messages: 4
Registered: November 2015
Junior Member
consider using

repository.getRefDatabase().getRefs("refs/heads/")?

it is a one liner to list the local branches.
Previous Topic:JGit blame ignore whitespace
Next Topic:A library that wraps around JGit
Goto Forum:
  


Current Time: Thu Apr 25 13:30:15 GMT 2024

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

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

Back to the top