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.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.DirectoryStream; import java.nio.file.DirectoryStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -85,7 +86,13 @@ public class FsBlobContainer extends AbstractBlobContainer {
@Override @Override
public void deleteBlob(String blobName) throws IOException { public void deleteBlob(String blobName) throws IOException {
Path blobPath = path.resolve(blobName); 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 @Override

View File

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