Check for null 'bufferedData' even in the path when 'subscription' is
null. Should also fix https://github.com/dart-lang/sdk/issues/26379

TEST=ci

Change-Id: Iacc18c8a38e2c5b36c5234495d39cf20bfd8bac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330201
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This commit is contained in:
asiva
2023-10-13 22:59:28 +00:00
committed by Commit Queue
parent 5362d9536b
commit 24155ef6f0
2 changed files with 13 additions and 3 deletions
+3 -3
View File
@@ -195,9 +195,9 @@ class _HttpDetachedIncoming extends Stream<Uint8List> {
return _HttpDetachedStreamSubscription(subscription, bufferedData, onData)
..resume();
} else {
// TODO(26379): add test for this branch.
return Stream<Uint8List>.fromIterable([bufferedData!]).listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
return Stream<Uint8List>.fromIterable([bufferedData ?? Uint8List(0)])
.listen(onData,
onError: onError, onDone: onDone, cancelOnError: cancelOnError);
}
}
}
@@ -7,9 +7,13 @@
import "dart:async";
import "dart:io";
// ignore: IMPORT_INTERNAL_LIBRARY
import "dart:_http" show TestingClass$_HttpHeaders, TestingClass$_HttpParser;
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
typedef _HttpParser = TestingClass$_HttpParser;
Future<void> testFormatException() async {
final server = await HttpServer.bind("127.0.0.1", 0);
server.listen((HttpRequest request) {
@@ -28,6 +32,12 @@ Future<void> testFormatException() async {
}
}
void testNullSubscriptionData() {
_HttpParser httpParser = new _HttpParser.requestParser();
httpParser.detachIncoming().listen((data) {}, onDone: () {});
}
main() {
asyncTest(testFormatException);
testNullSubscriptionData();
}