So literally as I was clicking submit on this after a couple days of poking I stumbled across what I believe is the answer.
The cookbook example only calls the .close()
method on the result of the cloneRepository()
's call()
method (A Git
instance). The API docs state that method should also call the .close
method of the underlying Repository
instance:
http://download.eclipse.org/jgit/site/4.0.1.201506240215-r/apidocs/org/eclipse/jgit/api/Git.html#close()
If the repository was opened by a static factory method in this class, then this method calls Repository.close() on the underlying repository instance.
However, I found that if I get the Repository
instance myself and call its .close()
method, all file system locks are released. I assume this is an omission in the JGit cookbook reference I was following and will submit an issue/pull.
Here is the working CFML code. Note the two .close()
calls at the bottom now.
Git = createObject( 'java', 'org.eclipse.jgit.api.Git' );
localPath = createObject( 'java', 'java.io.File' ).init( expandPath( 'temp' ) );
result = Git.cloneRepository()
.setURI( 'https://github.com/github/testrepo.git' )
.setDirectory( localPath )
.call();
result.getRepository().close();
result.close();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…