diff --git a/.github/workflows/dart_ci.yml b/.github/workflows/dart_ci.yml index dc9d130..1d0d037 100644 --- a/.github/workflows/dart_ci.yml +++ b/.github/workflows/dart_ci.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - sdk: [ 2.18.7 ] + sdk: [ 2.18.7 , 2.19.6] steps: - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v1.3 diff --git a/lib/src/lifecycle_module.dart b/lib/src/lifecycle_module.dart index bccd618..217e7c9 100644 --- a/lib/src/lifecycle_module.dart +++ b/lib/src/lifecycle_module.dart @@ -528,7 +528,7 @@ abstract class LifecycleModule extends SimpleModule with Disposable { try { manageDisposable(childModule); _childModules.add(childModule); - childModule._parentContext = _loadContext; + childModule.parentContext = _loadContext; await childModule.load(); try { @@ -554,7 +554,7 @@ abstract class LifecycleModule extends SimpleModule with Disposable { _didLoadChildModuleController.addError(error, stackTrace); completer.completeError(error, stackTrace); } finally { - childModule._parentContext = null; + childModule.parentContext = null; } }).catchError((Object error, StackTrace stackTrace) { _logger.severe( @@ -569,6 +569,12 @@ abstract class LifecycleModule extends SimpleModule with Disposable { return completer.future; } + /// Provide a way for a module to update its children's parentContext that is compatible with mocking in 2.19. + /// + /// This is only intended for use within this file and is marked protected. + @protected + set parentContext(SpanContext? context) => _parentContext = context; + /// Public method to suspend the module. /// /// Suspend indicates to the module that it should go into a low-activity @@ -1034,9 +1040,9 @@ abstract class LifecycleModule extends SimpleModule with Disposable { List> childResumeFutures = >[]; for (var child in _childModules.toList()) { childResumeFutures.add(Future.sync(() { - child._parentContext = _activeSpan?.context; + child.parentContext = _activeSpan?.context; return child.resume().whenComplete(() { - child._parentContext = null; + child.parentContext = null; }); })); } @@ -1071,9 +1077,9 @@ abstract class LifecycleModule extends SimpleModule with Disposable { List> childSuspendFutures = >[]; for (var child in _childModules.toList()) { childSuspendFutures.add(Future.sync(() async { - child._parentContext = _activeSpan?.context; + child.parentContext = _activeSpan?.context; return child.suspend().whenComplete(() { - child._parentContext = null; + child.parentContext = null; }); })); } @@ -1119,9 +1125,9 @@ abstract class LifecycleModule extends SimpleModule with Disposable { _willUnloadController.add(this); await Future.wait(_childModules.toList().map((child) { - child._parentContext = _activeSpan?.context; + child.parentContext = _activeSpan?.context; return child.unload().whenComplete(() { - child._parentContext = null; + child.parentContext = null; }); })); try {