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

Unified Diff: sdk/lib/async/stream_transformers.dart

Issue 2864443002: Revert "Throw when adding something to a closed sink and improve documentation." (Closed)
Patch Set: 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_controller.dart ('k') | sdk/lib/core/sink.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/async/stream_transformers.dart
diff --git a/sdk/lib/async/stream_transformers.dart b/sdk/lib/async/stream_transformers.dart
index d6a065503bf586db2bf84ed3e018c5500b058464..bfc83d6b58b4befbe215bd641956492567b85380 100644
--- a/sdk/lib/async/stream_transformers.dart
+++ b/sdk/lib/async/stream_transformers.dart
@@ -209,19 +209,12 @@ class _HandlerEventSink<S, T> implements EventSink<S> {
final _TransformDoneHandler<T> _handleDone;
/// The output sink where the handlers should send their data into.
- EventSink<T> _sink;
+ final EventSink<T> _sink;
_HandlerEventSink(
- this._handleData, this._handleError, this._handleDone, this._sink) {
- if (_sink == null) {
- throw new ArgumentError("The provided sink must not be null.");
- }
- }
-
- bool get _isClosed => _sink == null;
+ this._handleData, this._handleError, this._handleDone, this._sink);
void add(S data) {
- if (_isClosed) throw new StateError("Sink is closed");
if (_handleData != null) {
_handleData(data, _sink);
} else {
@@ -230,7 +223,6 @@ class _HandlerEventSink<S, T> implements EventSink<S> {
}
void addError(Object error, [StackTrace stackTrace]) {
- if (_isClosed) throw new StateError("Sink is closed");
if (_handleError != null) {
_handleError(error, stackTrace, _sink);
} else {
@@ -239,13 +231,10 @@ class _HandlerEventSink<S, T> implements EventSink<S> {
}
void close() {
- if (_isClosed) return;
- var sink = _sink;
- _sink = null;
if (_handleDone != null) {
- _handleDone(sink);
+ _handleDone(_sink);
} else {
- sink.close();
+ _sink.close();
}
}
}
« no previous file with comments | « sdk/lib/async/stream_controller.dart ('k') | sdk/lib/core/sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698