Skip to content

Commit

Permalink
Merge pull request #314 from Daespen/development
Browse files Browse the repository at this point in the history
Fixes FileUpload file streams not closing in case of exceptions
  • Loading branch information
FrankSchnicke authored Jun 30, 2023
2 parents 99855bd + 3d5dd63 commit e18af14
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,10 @@ private void createFile(String idShortPath, Object newValue, ISubmodelElement su

java.io.File targetFile = new java.io.File(filePath);

FileOutputStream outStream = new FileOutputStream(targetFile);
InputStream inStream = (InputStream) newValue;

IOUtils.copy(inStream, outStream);

inStream.close();
outStream.close();
try (FileOutputStream outStream = new FileOutputStream(targetFile);
InputStream inStream = (InputStream) newValue) {
IOUtils.copy(inStream, outStream);
}
}

private String getFilePath(String idShortPath, File file) {
Expand Down

0 comments on commit e18af14

Please sign in to comment.