fixed createListeningPoint in case of IOException #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a scenario where binding an IP address fails with IOException in createListeningPoint. The reason for that is that the network device with the given IP address is not there for some reason.
Our application has a mechanismn to retry binding after some time repeatedly because the missing network device will be added after some time and the next try to bind may be successful.
This will not work with the current implementation.
I've found out that the next try to call createListeningPoint() will not fail anymore although the network device is still not there and the IP address is therefore still not bindable. Even in the case where the IP address is bindable on the second try, a bind will not take place and we will end up in a listening point that does not work.
This happens because the implementation of createListeningPoint() stores the key for the listening point to a map called listeningPoints before the bind takes place (in messageProcessor.start()).
An IOExecption will be thrown but the map entry will not be removed. The next time createListeningPoint is called, it will find this map entry to returns it without starting the message processor.
My suggested fix is to store the listening point key to the map after having successfully called the messageProcessor.start() method to avoid having an orphaned entry in the listening points map.