I have found a really beautiful error, that can be very useful for readers.
@Override
public void storeInputStream(InputStream inputStream, FileAccessDetail fileAccessDetail) throws StorageException {
try (FileOutputStream out = new FileOutputStream(getPathFromDescriptor(fileAccessDetail))) {
IOUtils.copy(inputStream, out);
} catch (FileNotFoundException e) {
throw new StorageException("Unable to save inputrstream to location " + fileAccessDetail.toString(), e);
} catch (IOException e) {
throw new StorageException(e);
} finally {
try {
inputStream.close();
} catch (Exception e) {}
}
}
A stream is created and remembered for closing later, but overwritten by copy of another stream. So, both copies of that another stream will be closed, but the first stream - never.
Can I publish it on SO as a question and my answer?