spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Auditing doesn't work on entities in Datastore when running through DatastoreTemplate.performTransaction() #2603

Closed fpavageau closed 3 years ago

fpavageau commented 3 years ago

When using DatastoreTemplate.performTransaction() with spring-cloud-gcp-data-datastore 1.2.6.RELEASE, auditing doesn't work for entities.

That's because the new DatastoreTemplate instance created in performTransaction() does not have the ApplicationEventPublisher of the original one, which is the mechanism by which the AuditingHandler eventually gets called to set the auditing properties.

I've added a test to DatastoreTemplateAuditingTests in my fork which demonstrates the problem.

I also have a simple fix ready, if it's actually a bug and you want a PR.

meltsufin commented 3 years ago

Hi @fpavageau! Thanks for a detailed description, test, and fix! We'll be happy to accept the fix, if you can open a PR!

fpavageau commented 3 years ago

OK, I've squashed the test commit with the fix commit and opened the PR.