aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar buchgr <buchgr@google.com>2017-07-17 09:51:46 +0200
committerGravatar Jakob Buchgraber <buchgr@google.com>2017-07-17 10:11:16 +0200
commit9a45f55afc53d1844921bc90c1153ac449515f9e (patch)
treedbe1c78147dd60e1086b34fb9a0c02bf241ad0d5 /src/main/java/com/google/devtools/build
parent5dc23838b6013e957877f30220e0bdfcfe98f22c (diff)
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. PiperOrigin-RevId: 162178032
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java
index 599a282f54..4ee108e2e7 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java
@@ -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,7 +393,16 @@ final class ByteStreamUploader {
call.sendMessage(request);
} catch (IOException e) {
- call.cancel("Failed to read next chunk.", 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);
+ }
}
}
}