Grokking Spring Boot
0% completed
Proxy Pitfalls
A test calls two @Transactional methods of BookingService on the same injected bean. Inside book, the check "transaction active" prints true. Inside countBookings, it prints false, and the call then fails with a NullPointerException on a field that every BookingService initializes.
Nothing is wrong with the annotation, the transaction manager, or the test. The only difference is one keyword: countBookings is declared final. That keyword decides whether the call ever reaches the proxy's interceptors, and even which object runs the method.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%