-
-
Notifications
You must be signed in to change notification settings - Fork 429
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] Fix error handling with DNS resolution / Unknown host errors #3490
Conversation
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/modbus-binding-problems-with-silently-disconnected-items/139363/28 |
Unrelated jenkins error: org.openhab.core.thing: The following files had format violations: |
I side with Jenkins because you added the file with the format error. 🙂 |
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
ca676af
to
905d5ae
Compare
Thanks @wborn 👍 Now re-pushed the relevant stuff |
public ModbusSlaveConnection create(ModbusSlaveEndpoint endpoint) throws Exception { | ||
return endpoint.accept(new ModbusSlaveEndpointVisitor<ModbusSlaveConnection>() { | ||
public @Nullable ModbusSlaveConnection create(ModbusSlaveEndpoint endpoint) throws Exception { | ||
return endpoint.accept(new ModbusSlaveEndpointVisitor<@Nullable ModbusSlaveConnection>() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the thing IDE did not catch -- the anonymous ModbusSlaveEndpointVisitor
methods were returning @Nullable ModbusSlaveConnection
even though the generic type argument was <ModbusSlaveConnection>
@@ -238,8 +249,9 @@ public void passivateObject(ModbusSlaveEndpoint endpoint, @Nullable PooledObject | |||
} | |||
|
|||
@Override | |||
public boolean validateObject(ModbusSlaveEndpoint key, @Nullable PooledObject<ModbusSlaveConnection> p) { | |||
boolean valid = p != null && p.getObject().isConnected(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one likely raised unhandled NullPointerException before -- with unknown implications. Might not be expected in apache commons pool2
} | ||
|
||
@Override | ||
public void activateObject(ModbusSlaveEndpoint endpoint, @Nullable PooledObject<ModbusSlaveConnection> obj) | ||
throws Exception { | ||
public void activateObject(ModbusSlaveEndpoint endpoint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method raised NPE as well, but it was caught by the catch(Exception e)
block below... leading to message logged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
Potential fix for unhandled exception, leading to "unrecoverable" error state (openHAB restart needed). See the community post below.
I cannot verify whether this actually fixes the issue as the error is very rare
This would be good candidate for 3.x maintenance branch as well
From https://community.openhab.org/t/modbus-binding-problems-with-silently-disconnected-items/139363/28?u=ssalonen
logs from user showing error in
ModbusSlaveConnectionFactoryImpl:create
callinggetInetAddress
.getInetAddress
fails which leads tonull
connection beingcreate
d.followed then by