remote: Failed blob upload should close file handle.
Two cases:
- The upload succeeds and the Chunker consumes all its data and closes
the underlying data source.
- The upload fails and the Chunker doesn't close the data source, and
so we call reset() manually.
RELNOTES: None.
@@ -49,6 +49,8 @@ import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.annotation.concurrent.GuardedBy;
@@ -59,6 +61,8 @@ import javax.annotation.concurrent.GuardedBy;
*/
final class ByteStreamUploader {
+ private static final Logger logger = Logger.getLogger(ByteStreamUploader.class.getName());
+
private final String instanceName;
private final Channel channel;
private final CallCredentials callCredentials;
@@ -389,10 +393,19 @@ final class ByteStreamUploader {
call.sendMessage(request);
} catch (IOException e) {
+ try {
+ chunker.reset();
+ } catch (IOException e1) {
+ // This exception indicates that closing the underlying input stream failed.
+ // We don't expect this to ever happen, but don't want to swallow the exception
+ // completely.
+ logger.log(Level.WARNING, "Chunker failed closing data source.", e1);
+ } finally {
call.cancel("Failed to read next chunk.", e);
}
}
}
+ }
private String newResourceName(Digest digest) {
String resourceName =
