-
-
Notifications
You must be signed in to change notification settings - Fork 545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.7.x fix context stop #164
Conversation
@@ -80,7 +82,7 @@ public UserActor(@Assisted String id, | |||
//.log("actorWebsocketFlow", logger) | |||
.watchTermination((n, stage) -> { | |||
// When the flow shuts down, make sure this actor also stops. | |||
stage.thenAccept(f -> context().stop(self())); | |||
Patterns.pipe(stage, getContext().dispatcher()).to(self()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipe Done
to self
@@ -99,6 +101,8 @@ public Receive createReceive() { | |||
.match(UnwatchStocks.class, unwatchStocks -> { | |||
logger.info("Received message {}", unwatchStocks); | |||
unwatchStocks(unwatchStocks.symbols); | |||
}).match(Done.class, done -> { | |||
context().stop(self()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call context.stop
inside receive block where it's safe
@@ -62,6 +63,9 @@ class UserActor @Inject()(@Assisted id: String, @Named("stocksActor") stocksActo | |||
|
|||
case UnwatchStocks(symbols) => | |||
unwatchStocks(symbols) | |||
|
|||
case Done => | |||
context.stop(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call context.stop
from receive block
@@ -75,7 +79,7 @@ class UserActor @Inject()(@Assisted id: String, @Named("stocksActor") stocksActo | |||
// from the browse), using a coupled sink and source. | |||
Flow.fromSinkAndSourceCoupled(jsonSink, hubSource).watchTermination() { (_, termination) => | |||
// When the flow shuts down, make sure this actor also stops. | |||
termination.foreach(_ => context.stop(self)) | |||
termination.pipeTo(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pipe Done
to self
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @wsargent
Thanks as well, I will activate GitHub actions for this repo tonight, so we can run tests for it. |
Closing / Re-opening to trigger that newly added GHA checks |
Ahh this PR is against the 2.7.x branch! I should have looked closer. |
Fix for the context.stop bug described in https://discuss.lightbend.com/t/mergehub-is-not-cleaning-up-in-the-heap-area/9740