Skip to content

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented Apr 8, 2015

Resolves #17140 while remaining binary and source compatible

@drewhk
Copy link
Contributor

drewhk commented Apr 8, 2015

LGTM

Shoud this be backported to 2.3?

@ktoso
Copy link
Contributor Author

ktoso commented Apr 8, 2015

I think so, it can be considered a bug - in the docs we say this should work.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Apr 8, 2015
@akka-ci
Copy link

akka-ci commented Apr 8, 2015

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://jenkins.akka.io/job/pr-validator-per-commit-jenkins/2234/

}

currentState.timeout match {
case SomeMaxFiniteDuration ⇒ // effectively disable stateTimeout
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a meaningful distinction given a FiniteDuration of Long.MaxValue - 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effectively what I need to express "such big timeout that the akka scheduler would blow up anyway".
Thought using MaxValue would be cleanest as marker value. I could dig into the scheduler and find it's max and cut-off anything above it to => "effectively never", but that sounds a bit more magic than picking MaxValue as my marker.

Note: Users are not expected to use it directly, they'd do forMax(Inf) which I encode as this MaxValue marker. (Can't change types, if I could we'd change things to Duration from FiniteDuration and we'd be good).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just a workaround that the original code did not handle Duration.Inf although the forMax method (L146) accepts a Duration. The proper fix would be to change the signature of State to have a timeout of Option[Duration] instead of Option[FiniteDuration], but that would break binary compatiblility. So Konrad introduced this artifical marker that is introduced at L148 when a Duration.Inf is encountered, and which can be stored in the State case class without changing its signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason for this marker-hack is the FiniteDuration here: final case class State[S, D](stateName: S, stateData: D, timeout: Option[FiniteDuration], ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense. Apologies for barging in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, no worries – more often than not such barging in is pretty useful :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but @viktorklang 's comment is valid as in you should put a comment there to explain the "why".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agreed, I'll add one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment explaining the reasoning (and todo - we can fix it once we break compat).

@rkuhn
Copy link
Contributor

rkuhn commented Apr 9, 2015

LGTM

@ktoso ktoso force-pushed the wip-forMaxOverride-FSM-ktoso branch from 942cf6c to 8ae438b Compare April 9, 2015 15:31
@ktoso ktoso force-pushed the wip-forMaxOverride-FSM-ktoso branch from 8ae438b to bdedb10 Compare April 9, 2015 15:32
ktoso added a commit that referenced this pull request Apr 9, 2015
=act #17140 FSM: forMax(Inf) can now override stateTimeout
@ktoso ktoso merged commit 437e645 into akka:master Apr 9, 2015
@ktoso ktoso deleted the wip-forMaxOverride-FSM-ktoso branch April 9, 2015 15:34
ktoso added a commit to ktoso/akka that referenced this pull request Jan 11, 2016
=act akka#17140 FSM: forMax(Inf) can now override stateTimeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Akka-FSM stateTimeout ignores forMax Duration.Inf
6 participants