mirror of
https://github.com/apache/jclouds.git
synced 2025-02-17 23:46:13 +00:00
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
b1a2baee62
commit
9dae3a692e
@ -93,7 +93,12 @@ public abstract class Wire {
|
|||||||
long bytesRead = ByteStreams.copy(instream, out);
|
long bytesRead = ByteStreams.copy(instream, out);
|
||||||
if (bytesRead >= limit)
|
if (bytesRead >= limit)
|
||||||
logger.debug("over limit %d/%d: wrote temp file", 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
|
// we must call FileBackedOutputStream.reset to remove temporary file
|
||||||
return new FilterInputStream(out.asByteSource().getInput()) {
|
return new FilterInputStream(out.asByteSource().getInput()) {
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user