diff --git a/lib/ui/isolate_name_server.dart b/lib/ui/isolate_name_server.dart index 8dcbf79977ef7..0e33f4e0799eb 100644 --- a/lib/ui/isolate_name_server.dart +++ b/lib/ui/isolate_name_server.dart @@ -7,31 +7,29 @@ part of dart.ui; abstract class IsolateNameServer { // Looks up the [SendPort] associated with a given name. Returns null // if the name does not exist. + // + // `name` must not be null. static SendPort lookupPortByName(String name) { - if (name == null) { - throw new ArgumentError("'name' cannot be null."); - } + assert(name != null, "'name' cannot be null."); return _lookupPortByName(name); } // Registers a SendPort with a given name. Returns true if registration is // successful, false if the name entry already exists. + // + // `port` and `name` must not be null. static bool registerPortWithName(SendPort port, String name) { - if (name == null) { - throw new ArgumentError("'name' cannot be null."); - } - if (port == null) { - throw new ArgumentError("'port' cannot be null."); - } + assert(port != null, "'port' cannot be null."); + assert(name != null, "'name' cannot be null."); return _registerPortWithName(port, name); } // Removes a name to SendPort mapping given a name. Returns true if the // mapping was successfully removed, false if the mapping does not exist. + // + // `name` must not be null. static bool removePortNameMapping(String name) { - if (name == null) { - throw new ArgumentError("'name' cannot be null."); - } + assert(name != null, "'name' cannot be null."); return _removePortNameMapping(name); } diff --git a/testing/dart/isolate_name_server_test.dart b/testing/dart/isolate_name_server_test.dart index 4df83cf771b64..b8e4a342ec707 100644 --- a/testing/dart/isolate_name_server_test.dart +++ b/testing/dart/isolate_name_server_test.dart @@ -81,20 +81,6 @@ void main() { receivePort2.close(); }); - test('isolate name server null args', () { - // None of our IsolateNameServer methods should accept null. - expect(() => IsolateNameServer.lookupPortByName(null), throwsArgumentError); - expect(() => IsolateNameServer.registerPortWithName(null, 'abc'), - throwsArgumentError); - final receivePort = new ReceivePort(); - final sendPort = receivePort.sendPort; - expect(() => IsolateNameServer.registerPortWithName(sendPort, null), - throwsArgumentError); - expect(() => IsolateNameServer.removePortNameMapping(null), - throwsArgumentError); - receivePort.close(); - }); - test('isolate name server multi-isolate', () async { // Register our send port with the name server. final receivePort = new ReceivePort();