[ package:vm_service ] Fix issue where null was returned instead of @Instance of type Null

Also includes some cleanup for next release.

Fixes https://github.com/dart-lang/sdk/issues/44842

TEST=pkg/vm_service/test/regress_44842_test.dart

Change-Id: I250fac7c52d6d5344bd5c3ec1c143deaa97419d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182369
Reviewed-by: Gary Roumanis <grouma@google.com>
This commit is contained in:
Ben Konyi
2021-02-03 21:10:28 +00:00
parent 5a4b8240f9
commit f7cc17fb7e
8 changed files with 34 additions and 7 deletions
+1
View File
@@ -6,6 +6,7 @@
- Added `successors` iterable to `HeapSnapshotObject`, which provides a convenient way to
access children of a given object.
- Added `klass` getter to `HeapSnapshotObject`.
- Fixed issue where `null` could be returned instead of `InstanceRef` of type `Null`.
## 6.0.1
- Stable null-safe release.
+2 -1
View File
@@ -55,7 +55,8 @@ Object? createServiceObject(dynamic json, List<String> expectedTypes) {
} else {
return null;
}
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
} else if (_isNullInstance(json) &&
(!expectedTypes.contains('InstanceRef'))) {
// Replace null instances with null when we don't expect an instance to
// be returned.
return null;
@@ -0,0 +1,24 @@
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:vm_service/vm_service.dart';
import 'package:test/test.dart';
const Map<String, dynamic> kNullInstance = {
'type': '@Instance',
'id': 'instance/123',
'kind': 'Null',
'class': {
'type': '@Class',
'id': 'object/0',
'name': 'Null',
}
};
void main() {
test('Ensure createServiceObject handles Null @Instances properly', () {
expect(createServiceObject(kNullInstance, ['InstanceRef']), isNotNull);
expect(createServiceObject(kNullInstance, ['ClassRef']), isNull);
});
}
+1 -1
View File
@@ -535,7 +535,7 @@ Object? createServiceObject(dynamic json, List<String> expectedTypes) {
} else {
return null;
}
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
} else if (_isNullInstance(json) && (!expectedTypes.contains('InstanceRef'))) {
// Replace null instances with null when we don't expect an instance to
// be returned.
return null;
@@ -12,7 +12,7 @@ var tests = <VMTest>[
final result = await vm.invokeRpcNoUpgrade('getVersion', {});
expect(result['type'], 'Version');
expect(result['major'], 3);
expect(result['minor'], 42);
expect(result['minor'], 43);
expect(result['_privateMajor'], 0);
expect(result['_privateMinor'], 0);
},
@@ -12,7 +12,7 @@ var tests = <VMTest>[
var result = await vm.invokeRpcNoUpgrade('getVersion', {});
expect(result['type'], equals('Version'));
expect(result['major'], equals(3));
expect(result['minor'], equals(42));
expect(result['minor'], equals(43));
expect(result['_privateMajor'], equals(0));
expect(result['_privateMinor'], equals(0));
},
+1 -1
View File
@@ -15,7 +15,7 @@
namespace dart {
#define SERVICE_PROTOCOL_MAJOR_VERSION 3
#define SERVICE_PROTOCOL_MINOR_VERSION 42
#define SERVICE_PROTOCOL_MINOR_VERSION 43
class Array;
class EmbedderServiceHandler;
+3 -2
View File
@@ -1,8 +1,8 @@
# Dart VM Service Protocol 3.42
# Dart VM Service Protocol 3.43
> Please post feedback to the [observatory-discuss group][discuss-list]
This document describes of _version 3.42_ of the Dart VM Service Protocol. This
This document describes of _version 3.43_ of the Dart VM Service Protocol. This
protocol is used to communicate with a running Dart Virtual Machine.
To use the Service Protocol, start the VM with the *--observe* flag.
@@ -3948,5 +3948,6 @@ version | comments
3.40 | Added `IsolateFlag` object and `isolateFlags` property to `Isolate`.
3.41 | Added `PortList` object, `ReceivePort` `InstanceKind`, and `getPorts` RPC.
3.42 | Added `limit` optional parameter to `getStack` RPC.
3.43 | Updated heap snapshot format to include identity hash codes.
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss