MikeHT (137) [Avatar] Offline
#1
When I run this test, the message "Shutting down" from CreditCardProcessor.shutdown() comes out twice. Anyone else notice this and know why?
Kostis Kapelonis (63) [Avatar] Offline
#2
Hello

You have found a bug in the code! Congrats!

The reason is that the Billable basket calls shutdown by itself.

https://github.com/kkapelon/java-testing-with-spock/blob/28865dd63ca8779f059356b16a9e55135a51025b/chapter8/src/main/java/com/manning/spock/chapter8/eshop/BillableBasket.java#L15

So you see the message twice. Once from the Autoclose feature and once from the basket.

I will try to fix it!

Thank you.
Kostis Kapelonis (63) [Avatar] Offline
#3
Hello

I have fixed the bug

https://github.com/kkapelon/java-testing-with-spock/commit/4019194c1eb2d991add2f9e4f673bc3c4b414f71

If you now get the latest version of the code from git and run the test again you should see the message printed only once

Thank you

Kostis