diff --git a/CHANGELOG.md b/CHANGELOG.md index af04bc82..89ee9d2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project aims to adhere to [Semantic Versioning](http://semver.org/). - [Underlying stream is not closed when we throw a `MantaClientEncryptionException`](https://github.com/joyent/java-manta/issues/391) - [Underlying stream is not closed by `MantaEncryptedObjectInputStream` for range requests with certain ciphers](https://github.com/joyent/java-manta/issues/398) - [Exceptions relating to object type expectations are too generic](https://github.com/joyent/java-manta/issues/403) + - [Recursive delete fails to work when retries=0](https://github.com/joyent/java-manta/issues/407) ## [3.2.1] - 2017-12-01 ### Added diff --git a/java-manta-client-unshaded/src/main/java/com/joyent/manta/client/MantaClient.java b/java-manta-client-unshaded/src/main/java/com/joyent/manta/client/MantaClient.java index 9de89b2d..cd552ba8 100644 --- a/java-manta-client-unshaded/src/main/java/com/joyent/manta/client/MantaClient.java +++ b/java-manta-client-unshaded/src/main/java/com/joyent/manta/client/MantaClient.java @@ -314,6 +314,14 @@ public void deleteRecursive(final String path) throws IOException { * consumer of the SDK so that they can better tune their settings.*/ final AtomicInteger responseTimeouts = new AtomicInteger(0); + final int tries; + + if (config.getRetries() == null || config.getRetries() < 1) { + tries = 1; + } else { + tries = config.getRetries(); + } + while (true) { loops++; @@ -366,7 +374,7 @@ public void deleteRecursive(final String path) throws IOException { * delete it even though that operation may not be immediately * successful. */ toDelete.forEachOrdered(obj -> { - for (int i = 0; i < config.getRetries(); i++) { + for (int i = 0; i < tries; i++) { try { /* Don't bother deleting the file if it was marked as * deleted from the map step. */ diff --git a/java-manta-it/src/test/java/com/joyent/manta/client/MantaClientIT.java b/java-manta-it/src/test/java/com/joyent/manta/client/MantaClientIT.java index d00485e5..1194f56d 100644 --- a/java-manta-it/src/test/java/com/joyent/manta/client/MantaClientIT.java +++ b/java-manta-it/src/test/java/com/joyent/manta/client/MantaClientIT.java @@ -265,6 +265,24 @@ public final void testRecursiveDeleteObject() throws IOException { (MantaFunction) () -> mantaClient.get(testPathPrefix + "1")); } + @Test + public final void testRecursiveDeleteOnlyDirectories() throws IOException { + final String dir1 = String.format("%s1", testPathPrefix); + mantaClient.putDirectory(testPathPrefix + "1", null); + mantaClient.putDirectory(dir1, null); + + final String dir2 = String.format("%s/2", dir1); + mantaClient.putDirectory(dir2, null); + + final String dir3 = String.format("%s/3", dir2); + mantaClient.putDirectory(dir3, null); + + mantaClient.deleteRecursive(testPathPrefix + "1"); + + MantaAssert.assertResponseFailureStatusCode(404, RESOURCE_NOT_FOUND_ERROR, + (MantaFunction) () -> mantaClient.get(testPathPrefix + "1")); + } + @Test public final void verifyYouCanJustSpecifyDirNameWhenPuttingFile() throws IOException { final String name = UUID.randomUUID().toString();