try {mq.add(new Event(Event.STATE_RECEIVED, evt.getArg()));} catch(Exception e) {}
try {mq.add(new Event(Event.STATE_RECEIVED, state));} catch(Exception e) {}
    public void up(Event evt) {        int type=evt.getType();        Message msg;        /*if the queue is not available, there is no point in        *processing the message at all*/        if(mq == null) {            if(log.isErrorEnabled()) log.error("message queue is null");            return;        }        switch(type) {        case Event.MSG:            msg=(Message)evt.getArg();            if(!receive_local_msgs) {  // discard local messages (sent by myself to me)                if(local_addr != null && msg.getSrc() != null)                    if(local_addr.equals(msg.getSrc()))                        return;            }            break;        case Event.VIEW_CHANGE:            my_view=(View)evt.getArg();            // crude solution to bug #775120: if we get our first view *before* the CONNECT_OK,            // we simply set the state to connected            if(connected == false) {                connected=true;                connect_promise.setResult(Boolean.TRUE);            }            // unblock queueing of messages due to previous BLOCK event:            down(new Event(Event.STOP_QUEUEING));            if(!receive_views)  // discard if client has not set receving views to on                return;            //if(connected == false)            //  my_view=(View)evt.getArg();            break;        case Event.SUSPECT:            if(!receive_suspects)                return;            break;        case Event.GET_APPLSTATE:  // return the application's state            if(!receive_get_states) {  // if not set to handle state transfers, send null state                down(new Event(Event.GET_APPLSTATE_OK, null));                return;            }            break;        case Event.CONFIG:            HashMap config=(HashMap)evt.getArg();            if(config != null && config.containsKey("state_transfer"))                state_transfer_supported=((Boolean)config.get("state_transfer")).booleanValue();            break;        case Event.BLOCK:            // If BLOCK is received by application, then we trust the application to not send            // any more messages until a VIEW_CHANGE is received. Otherwise (BLOCKs are disabled),            // we queue any messages sent until the next VIEW_CHANGE (they will be sent in the            // next view)            if(!receive_blocks) {  // discard if client has not set 'receiving blocks' to 'on'                down(new Event(Event.BLOCK_OK));                down(new Event(Event.START_QUEUEING));                return;            }            break;        case Event.CONNECT_OK:            connect_promise.setResult(Boolean.TRUE);            break;        case Event.DISCONNECT_OK:            disconnect_promise.setResult(Boolean.TRUE);            break;        case Event.GET_STATE_OK:            Object state=evt.getArg();            if(state != null) {                try {mq.add(new Event(Event.STATE_RECEIVED, evt.getArg()));} catch(Exception e) {}            }            state_promise.setResult(evt.getArg());            break;        case Event.SET_LOCAL_ADDRESS:            local_addr_promise.setResult(evt.getArg());            break;        case Event.EXIT:            handleExit(evt);            return;  // no need to pass event up; already done in handleExit()        case Event.BLOCK_SEND: // emitted by FLOW_CONTROL            if(log.isInfoEnabled()) log.info("received BLOCK_SEND");            block_sending.set(Boolean.TRUE);            break;        case Event.UNBLOCK_SEND:  // emitted by FLOW_CONTROL            if(log.isInfoEnabled()) log.info("received UNBLOCK_SEND");            block_sending.set(Boolean.FALSE);            break;        default:            break;        }        // If UpHandler is installed, pass all events to it and return (UpHandler is e.g. a building block)        if(up_handler != null) {            up_handler.up(evt);            return;        }        if(type == Event.MSG || type == Event.VIEW_CHANGE || type == Event.SUSPECT ||                type == Event.GET_APPLSTATE || type == Event.BLOCK) {            try {                mq.add(evt);            }            catch(Exception e) {                if(log.isErrorEnabled()) log.error("exception: " + e);            }        }    }