Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modbus] Avoid unnecessary IllegalArgumentException on dispose #8297

Merged
merged 2 commits into from
Aug 15, 2020

Conversation

ssalonen
Copy link
Contributor

@ssalonen ssalonen commented Aug 15, 2020

If communication interface is closed, you cannot naturally interact with the device anymore. IllegalArgumentException is raised with all methods that would need to interact with the device.

In this commit, close and unregisterRegularPoll methods are not raising the exception anymore since they are essentially no-ops with closed communication interface. After all, close automatically unregisters all registered regular polls. Thus, it should be considered harmless to call these methods again on a closed instance, making them mostly idempotent.

This change was motivated by seeing the IllegalStateException in the wild (when disposing modbus poller thing), possibly triggered by certain dispose/initialize/reload of things: https://community.openhab.org/t/snip/102809/43

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@TravisBuddy
Copy link

Travis tests were successful

Hey @ssalonen,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@fwolter fwolter merged commit d834489 into openhab:2.5.x Aug 15, 2020
@fwolter fwolter added this to the 2.5.8 milestone Aug 15, 2020
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Sep 12, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
…ab#8297)

[modbus] Do not raise exception on no-op operation of comms. interface

If communication interface is closed, you cannot naturally interact with
the device anymore. IllegalArgumentException is raised with all methods
that would need to interact with the device.

In this commit, close() and unregisterRegularPoll methods are not
raising the exception anymore since they are essentially no-ops with
closed communication interface. After all, close automatically
unregisters all registered regular polls. Thus, it should be considered
harmless to call these methods again on a closed instance, making them
mostly idempotent.

This change was motivated by seeing the IllegalStateException in the
wild, possibly triggered by certain dispose/initialize steps of things:
https://community.openhab.org/t/snip/102809/43

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
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.

3 participants