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

Unified Diff: pkg/analysis_server/test/channel/byte_stream_channel_test.dart

Issue 2928703007: Catch exceptions in ByteStreamServerChannel._outputLine() and close the channel. (Closed)
Patch Set: Created 3 years, 6 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 | « pkg/analysis_server/lib/src/channel/byte_stream_channel.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/channel/byte_stream_channel_test.dart
diff --git a/pkg/analysis_server/test/channel/byte_stream_channel_test.dart b/pkg/analysis_server/test/channel/byte_stream_channel_test.dart
index 827dd75ca05d766a5763dd4e88780ec81b503f62..8b4693a4931819c28e28ea746b972c1ad3002f17 100644
--- a/pkg/analysis_server/test/channel/byte_stream_channel_test.dart
+++ b/pkg/analysis_server/test/channel/byte_stream_channel_test.dart
@@ -11,6 +11,7 @@ import 'package:analysis_server/src/channel/byte_stream_channel.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'package:typed_mock/typed_mock.dart';
import '../mocks.dart';
@@ -236,6 +237,25 @@ class ByteStreamServerChannelTest {
});
}
+ test_sendNotification_exceptionInSink() async {
+ // This IOSink asynchronously throws an exception on any writeln().
+ var outputSink = new _IOSinkMock();
+ when(outputSink.writeln(anyObject)).thenInvoke((object) {
+ new Timer(new Duration(milliseconds: 10), () {
+ throw '42';
+ });
+ });
+
+ var channel = new ByteStreamServerChannel(
+ null, outputSink, InstrumentationService.NULL_SERVICE);
+
+ // Attempt to send a notification.
+ channel.sendNotification(new Notification('foo'));
+
+ // An exception was thrown, it did not leak, but the channel was closed.
+ await channel.closed;
+ }
+
test_sendResponse() {
channel.sendResponse(new Response('foo'));
return outputLineStream.first
@@ -248,3 +268,5 @@ class ByteStreamServerChannelTest {
});
}
}
+
+class _IOSinkMock extends TypedMock implements IOSink {}
« no previous file with comments | « pkg/analysis_server/lib/src/channel/byte_stream_channel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698