diff --git a/runtime/observatory/tests/service/regress_44859_test.dart b/runtime/observatory/tests/service/regress_44859_test.dart new file mode 100644 index 00000000000..81120700d35 --- /dev/null +++ b/runtime/observatory/tests/service/regress_44859_test.dart @@ -0,0 +1,18 @@ +// 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:observatory/service_io.dart'; +import 'package:test/test.dart'; +import 'test_helper.dart'; + +void script() {} + +var tests = [ + (Isolate isolate) async { + Map metrics = await isolate.refreshDartMetrics(); + expect(metrics.length, 0); + }, +]; + +main(args) => runIsolateTests(args, tests, testeeBefore: script); diff --git a/runtime/observatory_2/tests/service_2/regress_44859_test.dart b/runtime/observatory_2/tests/service_2/regress_44859_test.dart new file mode 100644 index 00000000000..46bf69dbba2 --- /dev/null +++ b/runtime/observatory_2/tests/service_2/regress_44859_test.dart @@ -0,0 +1,18 @@ +// 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:observatory_2/service_io.dart'; +import 'package:test/test.dart'; +import 'test_helper.dart'; + +void script() {} + +var tests = [ + (Isolate isolate) async { + Map metrics = await isolate.refreshDartMetrics(); + expect(metrics.length, 0); + }, +]; + +main(args) => runIsolateTests(args, tests, testeeBefore: script); diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index a4a8c0bb807..4827248c236 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -3584,6 +3584,8 @@ static bool HandleNativeMetric(Thread* thread, JSONStream* js, const char* id) { static bool HandleDartMetricsList(Thread* thread, JSONStream* js) { Zone* zone = thread->zone(); const Class& metrics_cls = Class::Handle(zone, GetMetricsClass(thread)); + const auto& error = metrics_cls.EnsureIsFinalized(Thread::Current()); + ASSERT(error == Error::null()); const String& print_metrics_name = String::Handle(String::New("_printMetrics")); ASSERT(!print_metrics_name.IsNull());