[
https://issues.apache.org/jira/browse/HADOOP-19650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18015057#comment-18015057
]
ASF GitHub Bot commented on HADOOP-19650:
-----------------------------------------
bhattmanish98 commented on code in PR #7880:
URL: https://github.com/apache/hadoop/pull/7880#discussion_r2287009604
##########
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestFileSystemInitialization.java:
##########
@@ -81,21 +89,123 @@ public void testFileSystemCapabilities() throws Throwable {
final Path p = new Path("}");
// etags always present
- Assertions.assertThat(fs.hasPathCapability(p, ETAGS_AVAILABLE))
+ assertThat(fs.hasPathCapability(p, ETAGS_AVAILABLE))
.describedAs("path capability %s in %s", ETAGS_AVAILABLE, fs)
.isTrue();
// readahead always correct
- Assertions.assertThat(fs.hasPathCapability(p, CAPABILITY_SAFE_READAHEAD))
+ assertThat(fs.hasPathCapability(p, CAPABILITY_SAFE_READAHEAD))
.describedAs("path capability %s in %s", CAPABILITY_SAFE_READAHEAD, fs)
.isTrue();
// etags-over-rename and ACLs are either both true or both false.
final boolean etagsAcrossRename = fs.hasPathCapability(p,
ETAGS_PRESERVED_IN_RENAME);
final boolean acls = fs.hasPathCapability(p, FS_ACLS);
- Assertions.assertThat(etagsAcrossRename)
+ assertThat(etagsAcrossRename)
.describedAs("capabilities %s=%s and %s=%s in %s",
ETAGS_PRESERVED_IN_RENAME, etagsAcrossRename,
FS_ACLS, acls, fs)
.isEqualTo(acls);
}
+
+ /**
+ * Test that the AzureBlobFileSystem close without init works
+ * @throws Exception if an error occurs
+ */
+ @Test
+ public void testABFSCloseWithoutInit() throws Exception {
+ AzureBlobFileSystem fs = new AzureBlobFileSystem();
+ assertThat(fs.isClosed()).isTrue();
+ fs.close();
+ fs.initialize(this.getFileSystem().getUri(), getRawConfiguration());
+ assertThat(fs.isClosed()).isFalse();
+ fs.close();
+ assertThat(fs.isClosed()).isTrue();
+ }
+
+ /**
+ * Test that the AzureBlobFileSystem throws an exception
+ * when trying to perform an operation without initialization.
+ * @throws Exception if an error occurs
+ */
+ @Test
+ public void testABFSUninitializedFileSystem() throws Exception {
+ AzureBlobFileSystem fs = new AzureBlobFileSystem();
+ assertThat(fs.isClosed()).isTrue();
+ Path testPath = new Path("testPath");
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ fs::toString);
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.open(testPath, ONE_MB));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.create(testPath, FsPermission.getDefault(), false, ONE_MB,
+ fs.getDefaultReplication(testPath), ONE_MB, null));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.createNonRecursive(testPath, FsPermission.getDefault(),
false, ONE_MB,
+ fs.getDefaultReplication(testPath), ONE_MB, null));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.append(testPath, ONE_MB, null));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.rename(testPath, testPath));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.delete(testPath, true));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.listStatus(testPath));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.mkdirs(testPath, FsPermission.getDefault()));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.getFileStatus(testPath));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.breakLease(testPath));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.makeQualified(testPath));
+
+ intercept(IllegalStateException.class, ERR_INVALID_ABFS_STATE,
+ () -> fs.setOwner(testPath, "", ""));
Review Comment:
EMPTY_STRING can be used here
> ABFS: NPE when close() called on uninitialized filesystem
> ---------------------------------------------------------
>
> Key: HADOOP-19650
> URL: https://issues.apache.org/jira/browse/HADOOP-19650
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs/azure
> Affects Versions: 3.4.2
> Reporter: Steve Loughran
> Assignee: Anuj Modi
> Priority: Minor
> Labels: pull-request-available
>
> code
> {code}
> public void testABFSConstructor() throws Throwable {
> new AzureBlobFileSystem().close();
> }
> {code}
> stack
> {code}
> [ERROR] org.apache.hadoop.validator.TestRuntimeValid.testABFSConstructor --
> Time elapsed: 0.003 s <<< ERROR!
> java.lang.NullPointerException: Cannot invoke
> "org.apache.hadoop.fs.azurebfs.AzureBlobFileSystemStore.getClient()" because
> "this.abfsStore" is null
> at
> org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem.close(AzureBlobFileSystem.java:800)
> at
> org.apache.hadoop.validator.TestRuntimeValid.testABFSConstructor(TestRuntimeValid.java:49)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]