zhijiangW commented on a change in pull request #7183: [hotfix] Prefer compact
all exception to just throw last exception
URL: https://github.com/apache/flink/pull/7183#discussion_r236931440
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/zookeeper/filesystem/FileSystemStateStorageHelper.java
##########
@@ -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);
Review comment:
The exception for each attempt is probably same, so it seems not very
necessary for suppressing all the exceptions. The previous way for keeping
last exception should make sense for this case.
`ExceptionUtils.firstOrSuppressed` is more suitable for different exceptions
I think.
----------------------------------------------------------------
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