Skip to content

Commit

Permalink
Fixes FileUpload file streams not closing in case of exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Espen <[email protected]>
  • Loading branch information
Daespen committed Jun 29, 2023
1 parent 99855bd commit 3d5dd63
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 3d5dd63

Please sign in to comment.