feat: support the flattening syntax for supervising#1386
feat: support the flattening syntax for supervising#1386Roiocam merged 8 commits intoapache:mainfrom
Conversation
actor-typed-tests/src/test/java/jdocs/org/apache/pekko/typed/RouterTest.java
Outdated
Show resolved
Hide resolved
| val probe = TestProbe[Event]("evt") | ||
| val behv = Behaviors | ||
| .supervise(Behaviors.supervise(targetBehavior(probe.ref)).onFailure[Exc2](SupervisorStrategy.resume)) | ||
| .supervise(targetBehavior(probe.ref)) |
There was a problem hiding this comment.
The scala test migration is more than this, I will open a sperate PR for this.
actor-typed/src/main/scala/org/apache/pekko/actor/typed/Behavior.scala
Outdated
Show resolved
Hide resolved
| ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors.Supervise") | ||
| ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors$Supervise$") | ||
| ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors$Supervise") | ||
| ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.actor.typed.javadsl.Behaviors$Supervise") | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors.supervise") | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.javadsl.Behaviors.supervise") |
There was a problem hiding this comment.
I really think we should not just add things to mima backwards excludes, but also add comments why the exclusions are justified.
In this case it looks, to me, like the mima errors were actually legitimate and this PR breaks our binary compatibility promises documented at https://pekko.apache.org/docs/pekko/current/common/binary-compatibility-rules.html and https://github.com/apache/pekko/blob/main/CONTRIBUTING.md#binary-compatibility
To make things explicit: suppose we have an application 'A' which uses a library 'L' which depends on Pekko 1.0.0 . The point of the binary compatibility rules is that it should be safe for 'A' to update to Pekko 1.1.0 without breaking.
In this case, if L contained:
val s: Behaviors.Supervise = Behaviors.supervise(SupervisedActor.create())
... AFAICS this code would throw a runtime exception when executed with any Pekko version that has the change in this PR, because Behaviors.Supervise no longer exists.
There was a problem hiding this comment.
I really think we should not just add things to mima backwards excludes, but also add comments why the exclusions are justified.
I totally agree with that.
In this case it looks, to me, like the mima errors were actually legitimate
Yes.
What should we do when we face such API changes?
There was a problem hiding this comment.
What should we do when we face such API changes?
It depends on the situation. I haven't looked closely, but in this case, it looks like the SuperviseBehaviour was introduced to reduce code duplication between the two Behavior.Supervise classes, is that correct? I wonder if we could restore binary compatibility while still avoiding code duplication by restoring the Behavior.Supervise classes, but having them extends SuperviseBehaviour. If that does not work, possibly we should just choose to accept some duplication to achieve compatibility.
There was a problem hiding this comment.
I has been fix these binary compatibility via some duplicate code. would you take a look?
6265b0f to
facc0c8
Compare
d7bccaf to
f48f2dd
Compare
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.javadsl.Behaviors#Supervise.onFailure") | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors#Supervise.onFailure") |
There was a problem hiding this comment.
So these are OK because the old signatures returned Behavior, and the new ones return SuperviseBehavior, and since SuperviseBehavior extends Behavior every SuperviseBehavior is a Behavior? Sounds reasonable.
| # Change the return type of `Behaviors.supervise` to support flattened supervision | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.javadsl.Behaviors#Supervise.onFailure") | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors#Supervise.onFailure") | ||
| ProblemFilters.exclude[IncompatibleResultTypeProblem]("org.apache.pekko.actor.typed.scaladsl.Behaviors#Supervise.onFailure$extension") |
There was a problem hiding this comment.
This one as well (checked with javap)
|
Thanks @raboof, let we merged it. |
MOTIVATION
Continue #680
The original api wasn't flatening.
RELATED WORK