Skip to content
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

BasicCompletes Must Handle Latent Registration of recoverFrom(Exception) #12

Closed
VaughnVernon opened this issue Apr 7, 2019 · 2 comments

Comments

@VaughnVernon
Copy link
Contributor

When there is an exception thrown prior to the receiverFrom(Exception) being registered on BasicCompletes<T> the outcome should be delayed until the registration is completed. If there is never a registration of receiverFrom(Exception) then the outcome will be unknown.

@VaughnVernon
Copy link
Contributor Author

@Framstag Should be fixed. Please test and confirm.

@Framstag
Copy link

Framstag commented Apr 8, 2019

Updates to current master via bintray...

Modified example as follows:

private fun getUser(id: String): Completes<Response> {
        val userId = UserId.from(id)
        logger.info("Loading user $userId...")
        return stage.maybeActorOf(IUser::class.java,addressFactory.from(userId.toString()))
            .andThen {
                maybeUser ->
                logger.info("Return Response.Status.Ok")
                if (maybeUser.isEmpty) {
                    throw Exception("Not found")
                }
                Response.of(Response.Status.Ok, serialized(maybeUser.orElse(null)))
            }
            .recoverFrom {
                    e ->
                logger.error("Error:",e)
                logger.warn("Return Response.Status.NotFound: " + e.message)
                Response.of(Response.Status.NotFound) // Response
            }
    }

Exception is caught and printed as expected. Analysed code in debugger. Exception is stored during andThen() and later on handled during recoverFrom() call.

Rest call though does not return (curl is hanging).

@VaughnVernon VaughnVernon changed the title BasicCompletes Must Handle Latent Registration of receiverFrom(Exception) BasicCompletes Must Handle Latent Registration of recoverFrom(Exception) Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants