Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 20f17c7

Browse files
committed
[ Service ] Fix issue where FlagList was being populated with nulls in package:vm_service
Fixes dart-archive/vm_service_drivers#255 Change-Id: I4e7e3864263d2a2120594b73369ff629fbfd810b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110546 Commit-Queue: Ben Konyi <[email protected]> Reviewed-by: Kenzie Schmoll <[email protected]>
1 parent 938d3be commit 20f17c7

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pkg/vm_service/lib/vm_service.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,18 @@ Object createServiceObject(dynamic json, List<String> expectedTypes) {
3737
return json.map((e) => createServiceObject(e, expectedTypes)).toList();
3838
} else if (json is Map) {
3939
String type = json['type'];
40-
if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
40+
41+
// Not a Response type.
42+
if (type == null) {
43+
// If there's only one expected type, we'll just use that type.
44+
if (expectedTypes.length == 1) {
45+
type = expectedTypes.first;
46+
} else {
47+
return null;
48+
}
49+
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
50+
// Replace null instances with null when we don't expect an instance to
51+
// be returned.
4152
return null;
4253
}
4354
if (_typeFactories[type] == null) {

pkg/vm_service/tool/dart/generate_dart.dart

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,18 @@ Object createServiceObject(dynamic json, List<String> expectedTypes) {
458458
return json.map((e) => createServiceObject(e, expectedTypes)).toList();
459459
} else if (json is Map) {
460460
String type = json['type'];
461-
if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
461+
462+
// Not a Response type.
463+
if (type == null) {
464+
// If there's only one expected type, we'll just use that type.
465+
if (expectedTypes.length == 1) {
466+
type = expectedTypes.first;
467+
} else {
468+
return null;
469+
}
470+
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
471+
// Replace null instances with null when we don't expect an instance to
472+
// be returned.
462473
return null;
463474
}
464475
if (_typeFactories[type] == null) {

0 commit comments

Comments
 (0)