Chromium Code Reviews| Index: sdk/lib/io/io_sink.dart |
| diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart |
| index bae95792db6edafc5d70b7833865b6a8a0eb612b..8eda7ca193157d792be6fe097c5afc31e36b48e1 100644 |
| --- a/sdk/lib/io/io_sink.dart |
| +++ b/sdk/lib/io/io_sink.dart |
| @@ -15,8 +15,7 @@ part of dart.io; |
| * While a stream is being added using [addStream], any further attempts |
| * to add or write to the [IOSink] will fail until the [addStream] completes. |
| * |
| - * 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. |
| + * It is an error to add data to the [IOSink] after the sink is closed. |
| */ |
| abstract class IOSink implements StreamSink<List<int>>, StringSink { |
| /** |
| @@ -148,11 +147,24 @@ class _StreamSinkImpl<T> implements StreamSink<T> { |
| _StreamSinkImpl(this._target); |
| void add(T data) { |
| - if (_isClosed) return; |
| + if (_isClosed) { |
| + // TODO(29554): throw a StateError, and don't just report the problem. |
| + stderr.writeln("StreamSink is closed and adding to it is an error."); |
| + stderr.writeln(" See http://dartbug.com/29554."); |
| + stderr.writeln(StackTrace.current); |
|
Lasse Reichstein Nielsen
2017/05/08 11:31:08
I don't know enough about stderr to be sure this d
floitsch
2017/05/08 12:22:39
It completely interferes with the user's stderr.
H
|
| + return; |
| + } |
| _controller.add(data); |
| } |
| void addError(error, [StackTrace stackTrace]) { |
| + if (_isClosed) { |
| + // TODO(29554): throw a StateError, and don't just report the problem. |
| + stderr.writeln("StreamSink is closed and adding to it is an error."); |
| + stderr.writeln(" See http://dartbug.com/29554."); |
| + stderr.writeln(StackTrace.current); |
| + return; |
| + } |
| _controller.addError(error, stackTrace); |
| } |