diff options
author | 2017-07-17 09:51:46 +0200 | |
---|---|---|
committer | 2017-07-17 10:11:16 +0200 | |
commit | 9a45f55afc53d1844921bc90c1153ac449515f9e (patch) | |
tree | dbe1c78147dd60e1086b34fb9a0c02bf241ad0d5 /src/main/java/com/google/devtools/build | |
parent | 5dc23838b6013e957877f30220e0bdfcfe98f22c (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.java | 15 |
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); + } } } } |