The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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