Azure / azure-service-bus-java

☁️ Java client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
MIT License
60 stars 59 forks source link

Fix to allow to retry of failed close calls on entities #376

Open yvgopal opened 5 years ago

yvgopal commented 5 years ago

Fixes part 1 of #366 If for any reason, close call on a sender or receiver or messaging factory fails, the state of the object remains 'closing=true' and calling close again will simply return. This fix resets the closing flag to false if close fails, so client application can call close again. of course, calling close again doesn't guarantee that it succeeds. Even if close repeatedly fails, state of the objects will not be stuck in 'closing=true' state.

Another thing to handle concurrent or simultaneous close calls. If one threads called close and is waiting for close to finish, any other threads that call close will return immediately indicating the entity is closed. It is semantically wrong. This fix also addresses it.

Added tests to confirm it's behaving right.