Skip to content

Commit 9cfb33d

Browse files
committed
make sure the move does not fail on Windows
1 parent 38dee2a commit 9cfb33d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/index/IndexDatabaseTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,13 @@ public void setUpClass() throws Exception {
116116
// To avoid this, clone the Git repository.
117117
Path gitRepositoryRootPath = Path.of(repository.getSourceRoot(), "git");
118118
Path gitCheckoutPath = Path.of(repository.getSourceRoot(), "gitcheckout");
119-
Git.cloneRepository()
119+
Git git = Git.cloneRepository()
120120
.setURI(gitRepositoryRootPath.toFile().toURI().toString())
121121
.setDirectory(gitCheckoutPath.toFile())
122122
.call();
123+
// The Git object has to be closed, otherwise the move below would fail on Windows with
124+
// AccessDeniedException due to the file handle still being open.
125+
git.close();
123126
IOUtils.removeRecursive(gitRepositoryRootPath);
124127
Files.move(gitCheckoutPath, gitRepositoryRootPath);
125128

0 commit comments

Comments
 (0)