You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
There is an issue with the Pi4J I2C implementation that keeps crashing my application on shutdown:
Whenever there is an I2C read waiting to obtain the bus access lock and the thread is interrupted, the I2CBusImpl class catches the InterruptedException thrown by the tryLock() method and wraps it in a RuntimeException.
Unexpecting callers will have no idea what has just happened, probably not have a good handler for it or even just crash the thread entirely with an uncaught runtime exception.
Instead, after logging, the InterruptedException should just be re-thrown, so that callers clearly see that the method has failed because of an interrupt and can act accordingly.
Workaround is to put a catch block for RuntimeException on the caller's side and then check if getCause() returns an object of type InterruptedException.
The text was updated successfully, but these errors were encountered:
Reviewing this issue for v1.4 release. While I agree the exception probably should not be caught internally and masked as a runtime exception, changing this behavior would be a breaking API change for most of the I2CDevice methods.
Postponing fix to version 2.0 where breaking API changes are planned.
Hello!
There is an issue with the Pi4J I2C implementation that keeps crashing my application on shutdown:
Whenever there is an I2C read waiting to obtain the bus access lock and the thread is interrupted, the I2CBusImpl class catches the InterruptedException thrown by the tryLock() method and wraps it in a RuntimeException.
Unexpecting callers will have no idea what has just happened, probably not have a good handler for it or even just crash the thread entirely with an uncaught runtime exception.
Instead, after logging, the InterruptedException should just be re-thrown, so that callers clearly see that the method has failed because of an interrupt and can act accordingly.
https://github.com/Pi4J/pi4j/blob/f4a3f790a3be9d419d89525cedadffbad602a9c4/pi4j-core/src/main/java/com/pi4j/io/i2c/impl/I2CBusImpl.java#L267
Workaround is to put a catch block for RuntimeException on the caller's side and then check if getCause() returns an object of type InterruptedException.
The text was updated successfully, but these errors were encountered: