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

Unified Diff: sdk/lib/io/io_sink.dart

Issue 20036002: Don't throw exceptions when adding to a IOSink(StreamSink) after close. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Document the behaviour. Created 7 years, 5 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 | « no previous file | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/io_sink.dart
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
index a3310747fcc44447d4e675fbb26b10237840dbc8..b954a86d5ffeed71ac9f0e15677613193ed04251 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -11,8 +11,11 @@ part of dart.io;
* a [addStream] until the buffer is flushed.
*
* When the [IOSink] is bound to a stream (through [addStream]) any call
- * to the [IOSink] will throw a [StateError]. When the [addStream] compeltes,
+ * to the [IOSink] will throw a [StateError]. When the [addStream] completes,
* the [IOSink] will again be open for all calls.
+ *
+ * If data is added to the [IOSink] after the sink is closed, the data will be
+ * ignored. Use the [done] future to be notified when the [IOSink] is closed.
*/
abstract class IOSink implements StreamSink<List<int>>, StringSink {
factory IOSink(StreamConsumer<List<int>> target,
@@ -69,6 +72,7 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
}
void add(T data) {
+ if (_isClosed) return;
_controller.add(data);
}
« no previous file with comments | « no previous file | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698