I found that the COPY method wasn't closing file streams.
The servlet calls this to get the source data:
InputStream getResourceContent(ITransaction transaction, String resourceUri);
Then it does the copy by passing it to:
long setResourceContent(ITransaction transaction, String resourceUri,
InputStream content, String contentType, String characterEncoding);
But after doing the copy, it doesn't close the stream.
On further investigation, I found that LocalFileSystemStore was handling this by closing the stream inside its implementation of setResourceContent. This seems odd to me, because the stream is passed from the outside, which implies that the caller owns it, and thus the caller should surely be responsible for closing it.
Maybe this could be cleared up, either by flipping the responsibilities around to close it from the caller, or by clearly documenting on setResourceContent the contract that the implementation is expected to close the stream. (The caveat of the latter being that if there was an issue calling the method, the code which closes the stream might not be called, i.e., the only really safe place to have the closing code is at the caller.)
I found that the
COPYmethod wasn't closing file streams.The servlet calls this to get the source data:
Then it does the copy by passing it to:
But after doing the copy, it doesn't close the stream.
On further investigation, I found that
LocalFileSystemStorewas handling this by closing the stream inside its implementation ofsetResourceContent. This seems odd to me, because the stream is passed from the outside, which implies that the caller owns it, and thus the caller should surely be responsible for closing it.Maybe this could be cleared up, either by flipping the responsibilities around to close it from the caller, or by clearly documenting on
setResourceContentthe contract that the implementation is expected to close the stream. (The caveat of the latter being that if there was an issue calling the method, the code which closes the stream might not be called, i.e., the only really safe place to have the closing code is at the caller.)