Raised IOException on deleteBlob

Closes gh-18530.
This commit is contained in:
gfyoung 2016-06-10 15:00:23 +01:00 committed by Ali Beyad
parent c27237be9f
commit 0620a3d6c2
2 changed files with 10 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@ -85,7 +86,13 @@ public class FsBlobContainer extends AbstractBlobContainer {
@Override
public void deleteBlob(String blobName) throws IOException {
Path blobPath = path.resolve(blobName);
Files.deleteIfExists(blobPath);
try {
if (!Files.deleteIfExists(blobPath)) {
throw new IOException("File " + blobPath.toString() + " does not exist");
}
} catch (DirectoryNotEmptyException | SecurityException e) {
throw new IOException(e);
}
}
@Override

View File

@ -75,8 +75,8 @@ final class HdfsBlobContainer extends AbstractBlobContainer {
return fileContext.delete(new Path(path, blobName), true);
}
});
} catch (FileNotFoundException ok) {
// behaves like Files.deleteIfExists
} catch (FileNotFoundException e) {
throw new IOException(e);
}
}