digitaldan/jomnilink

Unsafe cast in notification listener dispatch.

Closed this issue · 0 comments

This code does not do a proper check before casting:

if (message instanceof ObjectStatus) {
  listener.objectStatusNotification((ObjectStatus) message);
} else {
  listener.otherEventNotification((OtherEventNotifications) message);
}	

This is causing issues in the openhab binding:

2017-07-05 20:28:11.709 [ERROR] [om.digitaldan.jomnilinkII.Connection] - Notifcation Handler Caught Exception
java.lang.ClassCastException: com.digitaldan.jomnilinkII.MessageTypes.AudioSourceStatus cannot be cast to com.digitaldan.jomnilinkII.MessageTypes.OtherEventNotifications
        at com.digitaldan.jomnilinkII.Connection$NotificationHandler.run(Connection.java:844)[263:org.openhab.binding.omnilink:2.2.0.201707050940]
        at java.lang.Thread.run(Thread.java:748)[:1.8.0_131]