Skip to content

Commit

Permalink
Add a retry for recursive delete on windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcin committed Apr 27, 2020
1 parent 22144c1 commit 04cb1d2
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.jcr.Binary;
Expand Down Expand Up @@ -115,10 +116,21 @@ public void testGetReadWriteFixture() throws Exception {
}
}

private void recursiveDeleteWithRetry(final File toDelete) throws IOException {
try {
FileUtils.deleteDirectory(toDelete);
} catch (IOException e) {
// retry if failed.
if (toDelete.exists()) {
FileUtils.deleteDirectory(toDelete);
}
}
}

@Test
public void testGetNodeStoreFixture_withWithoutFDS() throws Exception {
final File seedRepoHome = new File(testBaseDir, "testGetNodeStoreFixture_withFDS/seedRepo");
FileUtils.deleteDirectory(seedRepoHome);
recursiveDeleteWithRetry(seedRepoHome);
final File seedDir = new File(seedRepoHome, "segmentstore");
final File fdsDir = new File(seedRepoHome, "datastore");

Expand All @@ -127,7 +139,7 @@ public void testGetNodeStoreFixture_withWithoutFDS() throws Exception {
assertNull("blob store should be null without datastore dir", fixture.getBlobStore());
}

FileUtils.deleteDirectory(seedRepoHome);
recursiveDeleteWithRetry(seedRepoHome);
fdsDir.mkdirs();
assertTrue("fds dir should exist @ " + fdsDir.getAbsolutePath(), fdsDir.exists());
try (NodeStoreFixture fixture = JcrFactory.getNodeStoreFixture(false, seedDir)) {
Expand Down

0 comments on commit 04cb1d2

Please sign in to comment.