TisonKun closed pull request #7183: [hotfix] Prefer compact all exception to
just throw last exception
URL: https://github.com/apache/flink/pull/7183
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-runtime/src/main/java/org/apache/flink/runtime/zookeeper/filesystem/FileSystemStateStorageHelper.java
b/flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/filesystem/FileSystemStateStorageHelper.java
index fcad6176e7b..8af2e53417e 100644
---
a/flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/filesystem/FileSystemStateStorageHelper.java
+++
b/flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/filesystem/FileSystemStateStorageHelper.java
@@ -24,6 +24,7 @@
import org.apache.flink.runtime.state.RetrievableStateHandle;
import org.apache.flink.runtime.state.RetrievableStreamStateHandle;
import org.apache.flink.runtime.zookeeper.RetrievableStateStorageHelper;
+import org.apache.flink.util.ExceptionUtils;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.InstantiationUtil;
import org.apache.flink.util.Preconditions;
@@ -57,21 +58,20 @@ public FileSystemStateStorageHelper(Path rootPath, String
prefix) throws IOExcep
@Override
public RetrievableStateHandle<T> store(T state) throws Exception {
- Exception latestException = null;
+ Exception exception = null;
for (int attempt = 0; attempt < 10; attempt++) {
Path filePath = getNewFilePath();
try (FSDataOutputStream outStream = fs.create(filePath,
FileSystem.WriteMode.NO_OVERWRITE)) {
InstantiationUtil.serializeObject(outStream,
state);
- return new
RetrievableStreamStateHandle<T>(filePath, outStream.getPos());
- }
- catch (Exception e) {
- latestException = e;
+ return new
RetrievableStreamStateHandle<>(filePath, outStream.getPos());
+ } catch (Exception e) {
+ exception = ExceptionUtils.firstOrSuppressed(e,
exception);
}
}
- throw new Exception("Could not open output stream for state
backend", latestException);
+ throw new Exception("Could not open output stream for state
backend", exception);
}
private Path getNewFilePath() {
----------------------------------------------------------------
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