In another project we are working on, we have faced an issue when trying to read the file at the same time it's being writen by a heavy process.
This change is already applied in our repository, surpassing errors on corrupted file, but we think this change can be beneficial for other teams or projects.
It's supper simple, just move out from the try-catch block everything that is not related with IO operations (type checks, in memory object loops, ...). That frees the resource and, if it got write before closing, we don't face a java.io.StreamCorruptedException: unexpected EOF in middle of data block exception.
Committer Checklist (excluded from commit message)
In another project we are working on, we have faced an issue when trying to read the file at the same time it's being writen by a heavy process.
This change is already applied in our repository, surpassing errors on corrupted file, but we think this change can be beneficial for other teams or projects.
It's supper simple, just move out from the
try-catch
block everything that is not related with IO operations (type checks, in memory object loops, ...). That frees the resource and, if it got write before closing, we don't face ajava.io.StreamCorruptedException: unexpected EOF in middle of data block
exception.Committer Checklist (excluded from commit message)