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

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

Issue 2857393003: Adding to a closed sink throws.
Patch Set: Rebase Created 3 years, 7 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 | « sdk/lib/async/stream_transformers.dart ('k') | 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 25c9402e4129397542ce9dbc393e529a3f886865..c90051f63555aed9f182ba3ca83d4c121efde9ac 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -146,32 +146,16 @@ class _StreamSinkImpl<T> implements StreamSink<T> {
_StreamSinkImpl(this._target);
- void _reportClosedSink() {
- // TODO(29554): this is very brittle and depends on the layout of the
- // stderr class.
- if (this == stderr._sink) {
- // We can't report on stderr anymore (as we would otherwise
- // have an infinite recursion.
- throw new StateError("Stderr is closed.");
- }
- // 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);
- }
-
void add(T data) {
if (_isClosed) {
- _reportClosedSink();
- return;
+ throw new StateError("StreamSink is closed");
}
_controller.add(data);
}
void addError(error, [StackTrace stackTrace]) {
if (_isClosed) {
- _reportClosedSink();
- return;
+ throw new StateError("StreamSink is closed");
}
_controller.addError(error, stackTrace);
}
« no previous file with comments | « sdk/lib/async/stream_transformers.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698