GJL closed pull request #6915: [FLINK-10663][streaming] Fix NPE when
StreamingFileSink is closed without initialization.
URL: https://github.com/apache/flink/pull/6915
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/filesystem/StreamingFileSink.java
b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/filesystem/StreamingFileSink.java
index 6c7e135caf8..6f57fee81f3 100644
---
a/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/filesystem/StreamingFileSink.java
+++
b/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/functions/sink/filesystem/StreamingFileSink.java
@@ -375,6 +375,8 @@ public void invoke(IN value, SinkFunction.Context context)
throws Exception {
@Override
public void close() throws Exception {
- buckets.close();
+ if (buckets != null) {
+ buckets.close();
+ }
}
}
diff --git
a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/sink/filesystem/LocalStreamingFileSinkTest.java
b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/sink/filesystem/LocalStreamingFileSinkTest.java
index ab487d168bc..8bb35ff244a 100644
---
a/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/sink/filesystem/LocalStreamingFileSinkTest.java
+++
b/flink-streaming-java/src/test/java/org/apache/flink/streaming/api/functions/sink/filesystem/LocalStreamingFileSinkTest.java
@@ -59,6 +59,16 @@ public void testClosingWithoutInput() throws Exception {
}
}
+ @Test
+ public void testClosingWithoutInitializingStateShouldNotFail() throws
Exception {
+ final File outDir = TEMP_FOLDER.newFolder();
+
+ try (OneInputStreamOperatorTestHarness<Tuple2<String, Integer>,
Object> testHarness =
+
TestUtils.createRescalingTestSink(outDir, 1, 0, 100L, 124L)) {
+ testHarness.setup();
+ }
+ }
+
@Test
public void testTruncateAfterRecoveryAndOverwrite() throws Exception {
final File outDir = TEMP_FOLDER.newFolder();
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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