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

JaversAuditableRepositoryAspect does not properly handle thrown exceptions #355

Closed
Drizzt321 opened this Issue Apr 7, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@Drizzt321
Contributor

Drizzt321 commented Apr 7, 2016

Javers Spring support uses JaversAuditableRepositoryAspect on Spring-Data @Repository classes for @JaversAuditable or the Spring-Data CrudRepository interface. If an exception is thrown from one of those methods, then JaversAuditableRepositoryAspect, which uses @After will still execute and try and perform a versioning. According to Spring AOP Docs, @After will always execute, regardless of if there was an exception thrown or not. @AfterReturning instead executes only if the method returns normally.

Here's the original StackOverflow question for reference.

bartoszwalacik added a commit that referenced this issue Apr 13, 2016

Issue #355 JaversAuditableRepositoryAspect does not properly handle t…
…hrown exceptions

Solution is to use @AfterReturning which only runs on a noraml method exit, and @AfterThrowing which checks if @transactional was used on the @repository method, and if noRollbackFor or noRollbackForClassName is configured (still commit even if these Exceptions/Throwables are thrown) and matches the current Throwable, still proceed with the versioning.
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Apr 13, 2016

fixes merged to master, waiting for release

@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Apr 14, 2016

released in 1.6.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment