HADOOP-12726. Unsupported FS operations should throw UnsupportedOperationException. Contributed by Daniel Templeton.
This commit is contained in:
parent
143c59e4c5
commit
c37346d0e3
@ -356,12 +356,14 @@ public FSDataInputStream open(Path f, int bufferSize) throws IOException {
|
||||
@Override
|
||||
public FSDataOutputStream append(Path f, int bufferSize,
|
||||
Progressable progress) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Append is not supported "
|
||||
+ "by ChecksumFileSystem");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean truncate(Path f, long newLength) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Truncate is not supported "
|
||||
+ "by ChecksumFileSystem");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -297,7 +297,8 @@ public synchronized void seek(long pos) throws IOException {
|
||||
|
||||
@Override
|
||||
public boolean truncate(Path f, long newLength) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Truncate is not supported "
|
||||
+ "by ChecksumFs");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,7 +288,8 @@ public void close() throws IOException {
|
||||
@Override
|
||||
public FSDataOutputStream append(Path f, int bufferSize,
|
||||
Progressable progress) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Append is not supported "
|
||||
+ "by FTPFileSystem");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,6 @@ public class SFTPFileSystem extends FileSystem {
|
||||
"Can't make directory for path \"%s\" under \"%s\".";
|
||||
public static final String E_DIR_NOTEMPTY = "Directory: %s is not empty.";
|
||||
public static final String E_FILE_CHECK_FAILED = "File check failed";
|
||||
public static final String E_NOT_SUPPORTED = "Not supported";
|
||||
public static final String E_SPATH_NOTEXIST = "Source path %s does not exist";
|
||||
public static final String E_DPATH_EXIST =
|
||||
"Destination path %s already exist, cannot rename!";
|
||||
@ -578,7 +577,8 @@ public void close() throws IOException {
|
||||
public FSDataOutputStream append(Path f, int bufferSize,
|
||||
Progressable progress)
|
||||
throws IOException {
|
||||
throw new IOException(E_NOT_SUPPORTED);
|
||||
throw new UnsupportedOperationException("Append is not supported "
|
||||
+ "by SFTPFileSystem");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -485,10 +485,10 @@ private boolean checkAppend(FileSystem fs) {
|
||||
|
||||
try {
|
||||
fs.append(basePath);
|
||||
} catch (IOException ex) {
|
||||
if (ex.getMessage().equals("Not supported")) {
|
||||
} catch (UnsupportedOperationException ex) {
|
||||
canAppend = false;
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// Ignore. The operation is supported.
|
||||
}
|
||||
|
||||
return canAppend;
|
||||
|
@ -611,7 +611,7 @@ this precondition fails.
|
||||
|
||||
### `FSDataOutputStream append(Path p, int bufferSize, Progressable progress)`
|
||||
|
||||
Implementations MAY throw `UnsupportedOperationException`.
|
||||
Implementations without a compliant call SHOULD throw `UnsupportedOperationException`.
|
||||
|
||||
#### Preconditions
|
||||
|
||||
@ -630,7 +630,7 @@ by appending data to the existing list.
|
||||
|
||||
### `FSDataInputStream open(Path f, int bufferSize)`
|
||||
|
||||
Implementations MAY throw `UnsupportedOperationException`.
|
||||
Implementations without a compliant call SHOULD throw `UnsupportedOperationException`.
|
||||
|
||||
#### Preconditions
|
||||
|
||||
@ -944,7 +944,7 @@ to the `DFSFileSystem` implementation is an ongoing matter for debate.
|
||||
Joins multiple blocks together to create a single file. This
|
||||
is a little-used operation currently implemented only by HDFS.
|
||||
|
||||
Implementations MAY throw `UnsupportedOperationException`
|
||||
Implementations without a compliant call SHOULD throw `UnsupportedOperationException`.
|
||||
|
||||
#### Preconditions
|
||||
|
||||
@ -989,7 +989,7 @@ from specification.
|
||||
|
||||
Truncate file `p` to the specified `newLength`.
|
||||
|
||||
Implementations MAY throw `UnsupportedOperationException`.
|
||||
Implementations without a compliant call SHOULD throw `UnsupportedOperationException`.
|
||||
|
||||
#### Preconditions
|
||||
|
||||
|
@ -633,7 +633,8 @@ public FSDataOutputStream create(Path f, FsPermission permission,
|
||||
*/
|
||||
public FSDataOutputStream append(Path f, int bufferSize,
|
||||
Progressable progress) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Append is not supported "
|
||||
+ "by S3AFileSystem");
|
||||
}
|
||||
|
||||
|
||||
|
@ -421,7 +421,8 @@ protected URI canonicalizeUri(URI rawUri) {
|
||||
@Override
|
||||
public FSDataOutputStream append(Path f, int bufferSize,
|
||||
Progressable progress) throws IOException {
|
||||
throw new IOException("Not supported");
|
||||
throw new UnsupportedOperationException("Append is not supported "
|
||||
+ "by NativeS3FileSystem");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user