From 1e13b70fd3881cde6e2358089c7fd046cf2ea291 Mon Sep 17 00:00:00 2001 From: Tom McCormick Date: Tue, 17 Jan 2023 23:27:26 -0800 Subject: [PATCH] HDFS-16791 Fix build failures and unchecked exception warnings --- .../java/org/apache/hadoop/fs/FilterFs.java | 61 ++++++++++--------- .../hadoop/fs/TestGetEnclosingRoot.java | 2 +- .../AbstractContractGetEnclosingRoot.java | 2 +- .../fs/viewfs/TestViewFileSystemHdfs.java | 6 +- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java index 7d979b37b4a500..808f4bb32d27da 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java @@ -49,17 +49,17 @@ * pass all requests to the contained file system. Subclasses of * FilterFs 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; @@ -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); @@ -79,17 +79,17 @@ 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 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, @@ -97,7 +97,7 @@ public FSDataOutputStream createInternal(Path f, } @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); @@ -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); @@ -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 { @@ -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); @@ -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); @@ -217,7 +217,7 @@ public void mkdir(Path dir, FsPermission permission, boolean createParent) throws IOException, UnresolvedLinkException { checkPath(dir); myFs.mkdir(dir, permission, createParent); - + } @Override @@ -228,14 +228,14 @@ 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); @@ -243,7 +243,7 @@ public boolean truncate(Path f, long newLength) } @Override - public void renameInternal(Path src, Path dst) + public void renameInternal(Path src, Path dst) throws IOException, UnresolvedLinkException { checkPath(src); checkPath(dst); @@ -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 @@ -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); } @@ -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); } @@ -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> getDelegationTokens(String renewer) throws IOException { return myFs.getDelegationTokens(renewer); @@ -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); + } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java index 8cccbf750ffe8b..c3c5b6cf6c4468 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java @@ -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) () -> { FileSystem wFs = getFileSystem(); return wFs.getEnclosingRoot(new Path("/foo/bar")); }); diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java index c975d01597f676..02cdd302652d3e 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractGetEnclosingRoot.java @@ -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) () -> { FileSystem wFs = getContract().getTestFileSystem(); return wFs.getEnclosingRoot(new Path("/foo/bar")); }); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java index 1ff443df9e9c68..a4de359b51761e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemHdfs.java @@ -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 @@ -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) () -> { 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) () -> { FileSystem wFs = FileSystem.get(FsConstants.VIEWFS_URI, this.conf); return wFs.getEnclosingRoot(zone1); });