Repository navigation
Conversation
Motivation: A spec that overrides `testKit` with a `val`, e.g. `override val testKit = ActorTestKit()`, fails with a NullPointerException. `ScalaTestWithActorTestKitBase.patience` is a strict `val` that reads `testKit.testKitSettings` while the trait is initialized, before the subclass has assigned its overriding `testKit`. Modification: Make `patience` a `lazy val` so it is computed on first use, after construction. Add `ScalaTestWithActorTestKitSpec`. Result: Specs can override `testKit` with a `val`, and `patience` uses the overriding testkit's `DefaultTimeout`. Tests: - `actor-testkit-typed/Test/testOnly ...ScalaTestWithActorTestKitSpec` without the fix: failed with NullPointerException in `ScalaTestWithActorTestKitBase.testKit()` - `actor-testkit-typed/Test/testOnly org.apache.pekko.actor.testkit.typed.scaladsl.*` with the fix: 99 passed on 2.13.18 and 3.3.8 - `actor-testkit-typed/mimaReportBinaryIssues`: passed on 2.13.18 and 3.3.8 - scalafmt run on changed files References: Fixes apache#1140
Motivation: Making `patience` a `lazy val` broke every subclass that overrides it with `override implicit val patience`, e.g. `ReplicatedShardingSpec`, because a strict `val` cannot override a `lazy val`. User specs doing the same would no longer compile. Modification: Make `patience` a `def` instead. It is still evaluated on access rather than during trait initialization, and can be overridden by a `val`, `lazy val` or `def`. Result: Overriding `testKit` with a `val` works and existing `patience` overrides still compile. Tests: - `actor-testkit-typed/testOnly *ScalaTestWithActorTestKitSpec`: passed - `Test/compile` for cluster-sharding-typed, stream-tests, coordination, remote and actor-tests: passed - `actor-testkit-typed/mimaReportBinaryIssues`: passed - scalafmt run on changed files References: Fixes apache#1140
Motivation: The Check / Binary Compatibility job fails on Scala 3. Making `patience` a `def` leaves `ScalaTestWithActorTestKitBase` with no fields, so Scala 3 no longer emits the trait's synthetic `$init$`. Modification: Add a 2.0.x MiMa exclude for `ScalaTestWithActorTestKitBase.$init$`. Result: MiMa passes for actor-testkit-typed on Scala 2.13 and 3. Tests: - `++3.3.8 actor-testkit-typed/mimaReportBinaryIssues`: failed without the filter with the same error as CI, passed with it - `actor-testkit-typed/mimaReportBinaryIssues` (2.13): passed References: Refs apache#1140
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
A spec that overrides
testKitwith aval, e.g.override val testKit = ActorTestKit(), fails with aNullPointerException.ScalaTestWithActorTestKitBase.patienceis a strictvalthat readstestKit.testKitSettingswhile the trait is being initialized, before the subclass has assigned its overridingtestKit.Modification
patienceadef, so it is computed on access, after construction. Adef(rather than alazy val) keeps existingoverride implicit val patienceoverrides compiling.ScalaTestWithActorTestKitSpec.Result
Specs can override
testKitwith aval, andpatienceuses the overriding testkit'sDefaultTimeout.Tests
actor-testkit-typed/Test/testOnly ...ScalaTestWithActorTestKitSpecwithout the fix: failed withNullPointerExceptioninScalaTestWithActorTestKitBase.testKit()actor-testkit-typed/Test/testOnly org.apache.pekko.actor.testkit.typed.scaladsl.*with the fix: 99 passed on 2.13.18 and 3.3.8actor-testkit-typed/mimaReportBinaryIssues(baseline 1.0.0): passed on 2.13.18 and 3.3.8References
Fixes #1140