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

JaversAuditableRepositoryAspect does not properly handle thrown exceptions #355

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

Comments

@Drizzt321
Copy link
Contributor

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 pushed a commit that referenced this issue Apr 13, 2016
…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
Copy link
Member

fixes merged to master, waiting for release

@bartoszwalacik
Copy link
Member

released in 1.6.2

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

No branches or pull requests

2 participants