mirror of https://github.com/apache/jclouds.git
JCLOUDS-473: Close FileInputStream in Wire.copy
FileBackedOutputStream.asByteSource.getInput returns a FileInputStream which we do not close. We later call FileBackedOutputStream.reset which removes the underlying File. This fails on Windows which does not support deleting an open file and leaks resources on other platforms. Eagerly close to address this issue.
This commit is contained in:
parent
a656c7292f
commit
1f08b692cd
|
@ -93,7 +93,12 @@ public abstract class Wire {
|
|||
long bytesRead = ByteStreams.copy(instream, out);
|
||||
if (bytesRead >= limit)
|
||||
logger.debug("over limit %d/%d: wrote temp file", bytesRead, limit);
|
||||
wire(header, out.asByteSource().getInput());
|
||||
InputStream is = out.asByteSource().openStream();
|
||||
try {
|
||||
wire(header, is);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
// we must call FileBackedOutputStream.reset to remove temporary file
|
||||
return new FilterInputStream(out.asByteSource().getInput()) {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue