Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Fixed an infinite recursion in Java support library (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
jroper authored May 20, 2020
1 parent d2cc1ee commit c2809f4
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ final class EventSourcedImpl(_system: ActorSystem,
val service =
services.getOrElse(init.serviceName, throw new RuntimeException(s"Service not found: ${init.serviceName}"))
val handler = service.factory.create(new EventSourcedContextImpl(init.entityId))
val entityId = init.entityId
val thisEntityId = init.entityId

val startingSequenceNumber = (for {
snapshot <- init.snapshot
any <- snapshot.snapshot
} yield {
val snapshotSequence = snapshot.snapshotSequence
val context = new SnapshotContext with AbstractContext {
override def entityId: String = entityId
override def entityId: String = thisEntityId
override def sequenceNumber: Long = snapshotSequence
}
handler.handleSnapshot(ScalaPbAny.toJavaProto(any), context)
Expand All @@ -131,15 +131,15 @@ final class EventSourcedImpl(_system: ActorSystem,
.map(_.message)
.scan[(Long, Option[EventSourcedStreamOut.Message])]((startingSequenceNumber, None)) {
case (_, InEvent(event)) =>
val context = new EventContextImpl(entityId, event.sequence)
val context = new EventContextImpl(thisEntityId, event.sequence)
val ev = ScalaPbAny.toJavaProto(event.payload.get) // FIXME empty?
handler.handleEvent(ev, context)
(event.sequence, None)
case ((sequence, _), InCommand(command)) =>
if (entityId != command.entityId)
if (thisEntityId != command.entityId)
throw new IllegalStateException("Receiving entity is not the intended recipient of command")
val cmd = ScalaPbAny.toJavaProto(command.payload.get)
val context = new CommandContextImpl(entityId,
val context = new CommandContextImpl(thisEntityId,
sequence,
command.name,
command.id,
Expand Down

0 comments on commit c2809f4

Please sign in to comment.