Skip to content

Commit

Permalink
[ Service ] Fix issue where FlagList was being populated with nulls i…
Browse files Browse the repository at this point in the history
…n 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]>
  • Loading branch information
bkonyi committed Jul 25, 2019
1 parent 938d3be commit 20f17c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pkg/vm_service/lib/vm_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,18 @@ Object createServiceObject(dynamic json, List<String> expectedTypes) {
return json.map((e) => createServiceObject(e, expectedTypes)).toList();
} else if (json is Map) {
String type = json['type'];
if (_isNullInstance(json) && (!expectedTypes.contains(type))) {

// Not a Response type.
if (type == null) {
// If there's only one expected type, we'll just use that type.
if (expectedTypes.length == 1) {
type = expectedTypes.first;
} else {
return null;
}
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
// Replace null instances with null when we don't expect an instance to
// be returned.
return null;
}
if (_typeFactories[type] == null) {
Expand Down
13 changes: 12 additions & 1 deletion pkg/vm_service/tool/dart/generate_dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,18 @@ Object createServiceObject(dynamic json, List<String> expectedTypes) {
return json.map((e) => createServiceObject(e, expectedTypes)).toList();
} else if (json is Map) {
String type = json['type'];
if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
// Not a Response type.
if (type == null) {
// If there's only one expected type, we'll just use that type.
if (expectedTypes.length == 1) {
type = expectedTypes.first;
} else {
return null;
}
} else if (_isNullInstance(json) && (!expectedTypes.contains(type))) {
// Replace null instances with null when we don't expect an instance to
// be returned.
return null;
}
if (_typeFactories[type] == null) {
Expand Down

0 comments on commit 20f17c7

Please sign in to comment.