ThomasMarquardt commented on a change in pull request #1791: HADOOP-16785: wasb
to raise IOE if write() invoked on a closed stream
URL: https://github.com/apache/hadoop/pull/1791#discussion_r363435811
##########
File path:
hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azurebfs/ITestAzureBlobFileSystemCreate.java
##########
@@ -104,4 +107,39 @@ public void testCreateNonRecursive2() throws Exception {
.close();
assertIsFile(fs, testFile);
}
+
+ /**
+ * Attempts to use to the ABFS stream after it is closed.
+ */
+ @Test
+ public void testWriteAfterClose() throws Throwable {
+ final AzureBlobFileSystem fs = getFileSystem();
+ Path testPath = new Path(TEST_FOLDER_PATH, TEST_CHILD_FILE);
+ FSDataOutputStream out = fs.create(testPath);
+ out.close();
+ intercept(IOException.class, () -> out.write('a'));
+ intercept(IOException.class, () -> out.write(new byte[]{'a'}));
+ // hsync is not ignored on a closed stream
+ // out.hsync();
+ out.flush();
+ out.close();
+ }
+
+ /**
+ * Attempts to double close an ABFS output stream from within a
+ * FilterOutputStream.
+ * That class handles a double failure on close badly if the second
+ * exception rethrows the first.
+ */
+ @Test
+ public void testFilteredDoubleClose() throws Throwable {
Review comment:
Double close would have already been passing with these changes. To really
test the try-with-resources I think you need to modify the underlying blob
after fs.create but before flush so that flush fails and sets
AbfsOutputStream.lastError. For example, if you write some data to the blob so
that the position held by the AbfsOutputStream is invalid, flush may fail. For
example, the following test:
out = fs.create(path)
out.write('a');
// externally write data to the same path so that the next call to flush
will fail due to position being off.
intercept(IOException.class, () -> out.flush());
intercept(IOException.class, () -> out.close());
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]