Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: utils/pub/io.dart

Issue 11821062: Don't die because we write empty arrays to cURL. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/pub/curl_client.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 0309b90d9af0cc55fd32cb1a2c42f721b7135e30..8754706c31c42c135ef513e56cbd3d0a5ece97f1 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -599,7 +599,18 @@ class _OutputStreamConsumer implements StreamConsumer<List<int>, dynamic> {
// the following TODO.
var completed = false;
var completer = new Completer();
- stream.listen((data) => _outputStream.write(data), onDone: () {
+ stream.listen((data) {
+ // Writing empty data to a closed stream can cause errors.
+ if (data.isEmpty) return;
+
+ // TODO(nweiz): remove this try/catch when issue 7836 is fixed.
+ try {
+ _outputStream.write(data);
+ } catch (e, stack) {
+ if (!completed) completer.completeError(e, stack);
+ completed = true;
+ }
+ }, onDone: () {
_outputStream.close();
// TODO(nweiz): wait until _outputStream.onClosed is called once issue
// 7761 is fixed.
« no previous file with comments | « utils/pub/curl_client.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698