Skip to content

Commit

Permalink
HDFS-16791 Fix build failures and unchecked exception warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom McCormick committed Jan 18, 2023
1 parent 5d2a96c commit 1e13b70
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@
* pass all requests to the contained file system. Subclasses of
* <code>FilterFs</code> may further override some of these methods and may also
* provide additional methods and fields.
*
*
*/
@InterfaceAudience.Private
@InterfaceStability.Evolving /*Evolving for a release,to be changed to Stable */
public abstract class FilterFs extends AbstractFileSystem {
private final AbstractFileSystem myFs;

protected AbstractFileSystem getMyFs() {
return myFs;
}

protected FilterFs(AbstractFileSystem fs) throws URISyntaxException {
super(fs.getUri(), fs.getUri().getScheme(), false, fs.getUriDefaultPort());
myFs = fs;
Expand All @@ -69,7 +69,7 @@ protected FilterFs(AbstractFileSystem fs) throws URISyntaxException {
public Statistics getStatistics() {
return myFs.getStatistics();
}

@Override
public Path makeQualified(Path path) {
return myFs.makeQualified(path);
Expand All @@ -79,25 +79,25 @@ public Path makeQualified(Path path) {
public Path getInitialWorkingDirectory() {
return myFs.getInitialWorkingDirectory();
}

@Override
public Path getHomeDirectory() {
return myFs.getHomeDirectory();
}

@Override
public FSDataOutputStream createInternal(Path f,
EnumSet<CreateFlag> flag, FsPermission absolutePermission, int bufferSize,
short replication, long blockSize, Progressable progress,
ChecksumOpt checksumOpt, boolean createParent)
ChecksumOpt checksumOpt, boolean createParent)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.createInternal(f, flag, absolutePermission, bufferSize,
replication, blockSize, progress, checksumOpt, createParent);
}

@Override
public boolean delete(Path f, boolean recursive)
public boolean delete(Path f, boolean recursive)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.delete(f, recursive);
Expand All @@ -111,14 +111,14 @@ public BlockLocation[] getFileBlockLocations(Path f, long start, long len)
}

@Override
public FileChecksum getFileChecksum(Path f)
public FileChecksum getFileChecksum(Path f)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.getFileChecksum(f);
}

@Override
public FileStatus getFileStatus(Path f)
public FileStatus getFileStatus(Path f)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.getFileStatus(f);
Expand All @@ -137,12 +137,12 @@ public void access(Path path, FsAction mode) throws AccessControlException,
}

@Override
public FileStatus getFileLinkStatus(final Path f)
public FileStatus getFileLinkStatus(final Path f)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.getFileLinkStatus(f);
}

@Override
public FsStatus getFsStatus(final Path f) throws AccessControlException,
FileNotFoundException, UnresolvedLinkException, IOException {
Expand All @@ -159,7 +159,7 @@ public FsStatus getFsStatus() throws IOException {
public FsServerDefaults getServerDefaults() throws IOException {
return myFs.getServerDefaults();
}

@Override
public FsServerDefaults getServerDefaults(final Path f) throws IOException {
return myFs.getServerDefaults(f);
Expand All @@ -180,19 +180,19 @@ public int getUriDefaultPort() {
public URI getUri() {
return myFs.getUri();
}

@Override
public void checkPath(Path path) {
myFs.checkPath(path);
}

@Override
public String getUriPath(final Path p) {
return myFs.getUriPath(p);
}

@Override
public FileStatus[] listStatus(Path f)
public FileStatus[] listStatus(Path f)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.listStatus(f);
Expand All @@ -217,7 +217,7 @@ public void mkdir(Path dir, FsPermission permission, boolean createParent)
throws IOException, UnresolvedLinkException {
checkPath(dir);
myFs.mkdir(dir, permission, createParent);

}

@Override
Expand All @@ -228,22 +228,22 @@ public FSDataInputStream open(final Path f) throws AccessControlException,
}

@Override
public FSDataInputStream open(Path f, int bufferSize)
public FSDataInputStream open(Path f, int bufferSize)
throws IOException, UnresolvedLinkException {
checkPath(f);
return myFs.open(f, bufferSize);
}

@Override
public boolean truncate(Path f, long newLength)
public boolean truncate(Path f, long newLength)
throws AccessControlException, FileNotFoundException,
UnresolvedLinkException, IOException {
checkPath(f);
return myFs.truncate(f, newLength);
}

@Override
public void renameInternal(Path src, Path dst)
public void renameInternal(Path src, Path dst)
throws IOException, UnresolvedLinkException {
checkPath(src);
checkPath(dst);
Expand All @@ -257,13 +257,13 @@ public void renameInternal(final Path src, final Path dst,
ParentNotDirectoryException, UnresolvedLinkException, IOException {
myFs.renameInternal(src, dst, overwrite);
}

@Override
public void setOwner(Path f, String username, String groupname)
throws IOException, UnresolvedLinkException {
checkPath(f);
myFs.setOwner(f, username, groupname);

}

@Override
Expand All @@ -281,14 +281,14 @@ public boolean setReplication(Path f, short replication)
}

@Override
public void setTimes(Path f, long mtime, long atime)
public void setTimes(Path f, long mtime, long atime)
throws IOException, UnresolvedLinkException {
checkPath(f);
myFs.setTimes(f, mtime, atime);
}

@Override
public void setVerifyChecksum(boolean verifyChecksum)
public void setVerifyChecksum(boolean verifyChecksum)
throws IOException, UnresolvedLinkException {
myFs.setVerifyChecksum(verifyChecksum);
}
Expand All @@ -299,7 +299,7 @@ public boolean supportsSymlinks() {
}

@Override
public void createSymlink(Path target, Path link, boolean createParent)
public void createSymlink(Path target, Path link, boolean createParent)
throws IOException, UnresolvedLinkException {
myFs.createSymlink(target, link, createParent);
}
Expand All @@ -308,12 +308,12 @@ public void createSymlink(Path target, Path link, boolean createParent)
public Path getLinkTarget(final Path f) throws IOException {
return myFs.getLinkTarget(f);
}

@Override // AbstractFileSystem
public String getCanonicalServiceName() {
return myFs.getCanonicalServiceName();
}

@Override // AbstractFileSystem
public List<Token<?>> getDelegationTokens(String renewer) throws IOException {
return myFs.getDelegationTokens(renewer);
Expand Down Expand Up @@ -459,4 +459,9 @@ public MultipartUploaderBuilder createMultipartUploader(final Path basePath)
throws IOException {
return myFs.createMultipartUploader(basePath);
}

@Override
public Path getEnclosingRoot(Path path) throws IOException {
return myFs.getEnclosingRoot(path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void testEnclosingRootWrapped() throws Exception {
assertEquals(fs.getEnclosingRoot(new Path("/foo/bar")), root);

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Path p = (Path) ugi.doAs((PrivilegedExceptionAction) () -> {
Path p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = getFileSystem();
return wFs.getEnclosingRoot(new Path("/foo/bar"));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void testEnclosingRootWrapped() throws Exception {
assertEquals(fs.getEnclosingRoot(new Path("/foo/bar")), root);

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Path p = (Path) ugi.doAs((PrivilegedExceptionAction) () -> {
Path p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = getContract().getTestFileSystem();
return wFs.getEnclosingRoot(new Path("/foo/bar"));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ public void testEnclosingRootFailure() throws Exception {
LambdaTestUtils.intercept(IllegalArgumentException.class,
()-> fsView.getEnclosingRoot(fs1));
LambdaTestUtils.intercept(IllegalArgumentException.class,
()-> fsView.getEnclosingRoot(new Path("hdfs://fakeauthority/")));
()-> fsView.getEnclosingRoot(new Path("hdfs://fakeAuthority/")));
}

@Test
Expand All @@ -576,12 +576,12 @@ public void testEnclosingRootWrapped() throws Exception {
hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash);

UserGroupInformation ugi = UserGroupInformation.createRemoteUser("foo");
Path p = (Path) ugi.doAs((PrivilegedExceptionAction) () -> {
Path p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = FileSystem.get(FsConstants.VIEWFS_URI, this.conf);
return wFs.getEnclosingRoot(zone);
});
assertEquals(p, getViewFsPath("/data", fsView));
p = (Path) ugi.doAs((PrivilegedExceptionAction) () -> {
p = ugi.doAs((PrivilegedExceptionAction<Path>) () -> {
FileSystem wFs = FileSystem.get(FsConstants.VIEWFS_URI, this.conf);
return wFs.getEnclosingRoot(zone1);
});
Expand Down

0 comments on commit 1e13b70

Please sign in to comment.