If I understand correctly, the expectation is that *no* StateTimeout should 
be fired - due to the:

stay() forMax(Duration.Inf)

`forMax` is defined as such:

    def forMax(timeout: Duration): State[S, D] = timeout match {
      case f: FiniteDuration ⇒ copy(timeout = Some(f))
      case _                 ⇒ copy(timeout = None)
    }

When calling `when(..., stateTimeout = 5.seconds)`, I observed that a 
`register` method gets called. It updates a mutable map with a time-out.

  final def when(stateName: S, stateTimeout: FiniteDuration = 
null)(stateFunction: StateFunction): Unit =
    register(stateName, stateFunction, Option(stateTimeout))

Lastly, I saw that, per the recent PR's changes (noted above by Konrad), 
the following if-condition will evaluate to *true*, I believe, since 
`notifies` gets set to *true* by default 
- 
https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/FSM.scala#L126.

https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/FSM.scala#L644-649

I'll keep looking at it tomorrow. But I wanted to post here to make sure 
I'm on the right path.

Thanks,
Kevin

On Monday, April 6, 2015 at 7:25:14 AM UTC-4, Konrad Malawski wrote:
>
> Thanks for reporting!
>
> -- 
> Cheers,
> Konrad 'ktoso’ Malawski
> Akka <http://akka.io> @ Typesafe <http://typesafe.com>
>
> On 6 April 2015 at 12:53:30, folex ([email protected] <javascript:>) wrote:
>
> https://github.com/akka/akka/issues/17140
>
> On Friday, April 3, 2015 at 6:11:02 PM UTC+3, Akka Team wrote: 
>>
>>  Hi folex,
>> thanks for reporting.
>>
>> Around that time this commit was merged into FSM 
>> https://github.com/akka/akka/commit/2c88bb116903b42decb9d8063dc410325a9b9d29
>> which indeed changes semantics of `stay()` slightly (see documentation). 
>> It changed when state transitions are triggered (the events).
>>
>> I think there's a different inconsistency uncovered by your example 
>> though... 
>> When using `goto(currentState) forMax Duration.Inf` it was ignored (it 
>> seems, didn't debug yet, just observed),
>> the same happens with `stay() forMax Duration.Inf`. However `stay() 
>> forMax 10.minutes` did override the 5seconds timeout...
>>
>> I think this is a bug and we should investigate in depth - would you mind 
>> opening an issue on http://github.com/akka/akka/issues?
>> If you'd like to a PR fixing it would be even more awesome! :-)
>> Thanks a lot in advance!
>>
>> -- Konrad
>>  
>> On Fri, Apr 3, 2015 at 10:38 AM, folex <[email protected]> wrote:
>>
>>>   sealed trait State
>>> import scala.concurrent.duration._
>>> import akka.actor._
>>>
>>> sealed trait Data
>>> case object Initial extends State
>>> case object Waiting extends State
>>> case object Empty extends Data
>>>
>>> class FSMActor extends LoggingFSM[State, Data] {
>>>       startWith(Initial, Empty)
>>>      
>>>       when(Initial) {
>>>         case Event("Wait", _) => goto(Waiting)
>>>       }
>>>
>>>       when(Waiting, stateTimeout = 5.seconds) {
>>>         case Event("Message", _) => println(self.path.name + " got 
>>> message")
>>>         stay() forMax (Duration.Inf)
>>>
>>>         case Event(StateTimeout, _) => println(self.path.name + " got 
>>> StateTimeout :("); stay()
>>>       }
>>> }
>>>
>>> val system = ActorSystem("system")
>>> val fsm = system.actorOf(Props(new FSMActor), "fsm")
>>> fsm ! "Wait"
>>> fsm ! "Message"
>>>
>>>  
>>> (code on lpaste: http://lpaste.net/130078) 
>>>
>>> But actor keeps receiving StateTimeout messages
>>>
>>> I'm using 2.4-SNAPSHOT, and before Apr 02 update, StateTimeout wasn't 
>>> fired even without `forMax` in stay() clause.
>>>
>>> Maybe the problem lays in my understanding of stateTimeout argument? 
>>> Should I use setStateTimeout or something?
>>>
>>> Thanks in advance.
>>>  --
>>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>>> >>>>>>>>>> Check the FAQ: 
>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>> >>>>>>>>>> Search the archives: 
>>> https://groups.google.com/group/akka-user
>>> ---
>>> You received this message because you are subscribed to the Google 
>>> Groups "Akka User List" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>  
>>
>>
>> --
>>   Akka Team
>> Typesafe - Reactive apps on the JVM
>> Blog: letitcrash.com
>> Twitter: @akkateam
>>   
>  --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: 
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups 
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected] 
> <javascript:>.
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to