Skip to content

fix(iot-dev): Fix bug where multiplexed client had more session handlers than expected#1341

Merged
timtay-microsoft merged 5 commits intomasterfrom
timtay/sessionHandler
Sep 9, 2021
Merged

fix(iot-dev): Fix bug where multiplexed client had more session handlers than expected#1341
timtay-microsoft merged 5 commits intomasterfrom
timtay/sessionHandler

Conversation

@timtay-microsoft
Copy link
Copy Markdown
Member

If a multiplexing client tried to open, failed due to a network issue or something similar, and then later tried to open again, the session handler list would contain 2 session handlers for each multiplexed device instead of the expected 1. The issue was that the catch logic within the open call didn't clear the session handler list in the event of a network issue or interruption.

#1336

…dlers than expected

If a multiplexing client tried to open, failed due to a network issue or something similar, and then later tried to open again, the session handler list would contain 2 session handlers for each multiplexed device instead of the expected 1. The issue was that the catch logic within the open call didn't clear the session handler list in the event of a network issue or interruption.
if (existingAmqpsSessionHandler.getDeviceId().equals(deviceClientConfig.getDeviceId()))
{
amqpsSessionHandler = existingAmqpsSessionHandler;
break;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This session handler was retrieved from the local state, but later added to the same list it was retrieved from for some reason. Now we just return it once it is found. No need to add a duplicate session handler to the list of session handlers

else
{
// Since a session is being added for the reconnecting device, it can be removed from the reconnectingDeviceSessionHandlers collection
this.reconnectingDeviceSessionHandlers.remove(amqpsSessionHandler);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list is of multiplexed devices that are temporarily unregistered for reconnection purposes. Since the addSessionHandler call is used to re-add the unregistered device, now is the appropriate time to remove the device from this list.

@timtay-microsoft
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).


private void clearLocalState()
{
this.sessionHandlers.clear();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be any need to nullcheck anything in here? Just seeing it being called in the catch so it might give an unexpected NRE.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. Both of these queues are final, so they are instantiated once and never set to null

@timtay-microsoft
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@timtay-microsoft
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@timtay-microsoft
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants