Add instanceof query before casting objects
@@ -26,6 +26,7 @@ import iso.std.iso_iec._24727.tech.schema.ConnectionHandleType;
import java.math.BigInteger;
import javax.annotation.Nonnull;
import org.openecard.common.event.EventType;
+import org.openecard.common.event.IfdEventObject;
import org.openecard.common.interfaces.EventFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,8 +54,13 @@ public class CardRemovedFilter implements EventFilter {
LOG.debug("Received event.");
if (t.equals(EventType.CARD_REMOVED)) {
LOG.debug("Received CARD_REMOVED event.");
- ConnectionHandleType conHandle = (ConnectionHandleType) o;
- if (ifdName.equals(conHandle.getIFDName()) && slotIdx.equals(conHandle.getSlotIndex())) {
+ ConnectionHandleType conHandle = null;
+ if (o instanceof IfdEventObject) {
+ conHandle = ((IfdEventObject) o).getHandle();
+ } else if (o instanceof ConnectionHandleType) {
+ conHandle = (ConnectionHandleType) o;
+ }
+ if (conHandle != null && ifdName.equals(conHandle.getIFDName()) && slotIdx.equals(conHandle.getSlotIndex())) {
LOG.info("Card removed during processing of EAC GUI.");
return true;
} else {
