From 6f815d53fec72c8d56e302de2822c18eb9460bee Mon Sep 17 00:00:00 2001 From: Elijah Zupancic Date: Thu, 29 Mar 2018 15:32:03 -0700 Subject: [PATCH 1/4] Added fix for #407 --- .../main/java/com/joyent/manta/client/MantaClient.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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..313097a1 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 retries; + + if (config.getRetries() == null || config.getRetries() < 1) { + retries = 1; + } else { + retries = 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 < retries; i++) { try { /* Don't bother deleting the file if it was marked as * deleted from the map step. */ From ebba434c3c5ed2fb9aefa98a1922ba2f483e1f2b Mon Sep 17 00:00:00 2001 From: Elijah Zupancic Date: Thu, 29 Mar 2018 15:32:50 -0700 Subject: [PATCH 2/4] Added additional integration test --- .../com/joyent/manta/client/MantaClientIT.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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(); From 04ff63aa571491458e62983d598d7172c73f9b98 Mon Sep 17 00:00:00 2001 From: Elijah Zupancic Date: Thu, 29 Mar 2018 15:33:33 -0700 Subject: [PATCH 3/4] Changed retries to tries --- .../main/java/com/joyent/manta/client/MantaClient.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 313097a1..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,12 +314,12 @@ 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 retries; + final int tries; if (config.getRetries() == null || config.getRetries() < 1) { - retries = 1; + tries = 1; } else { - retries = config.getRetries(); + tries = config.getRetries(); } while (true) { @@ -374,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 < retries; 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. */ From 8a4fadaf30a0e6584a8894608d9c9d2397c31e62 Mon Sep 17 00:00:00 2001 From: Elijah Zupancic Date: Mon, 2 Apr 2018 10:08:15 -0700 Subject: [PATCH 4/4] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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