Program: 146258
Project: 146258
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MsgId.START_SEARCH:
    Bundle data=msg.getData();
  String name=data.getString(Router.PEER_NAME);
String addr=data.getString(Router.PEER_ADDR);
String port=data.getString(Router.PEER_PORT);
int timeout=data.getInt(Router.TIMEOUT);
router.startPeerSearch(sessionId,new DeviceInfo(name,addr,port),timeout);
break;
case MsgId.STOP_SEARCH:
router.stopPeerSearch(sessionId);
break;
case MsgId.ACCEPT_CONNECTION:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
router.acceptConnection(sessionId,new DeviceInfo(name,addr,port));
break;
case MsgId.DENY_CONNECTION:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
int denyCode=data.getInt(Router.CONN_DENY_CODE);
router.denyConnection(sessionId,new DeviceInfo(name,addr,port),denyCode);
break;
case MsgId.CONNECT:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
byte[] token=data.getByteArray(Router.AUTHENTICATION_TOKEN);
timeout=data.getInt(Router.TIMEOUT);
router.connectPeer(sessionId,new DeviceInfo(name,addr,port),token,timeout);
break;
case MsgId.DISCONNECT:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
router.disconnectPeer(sessionId,new DeviceInfo(name,addr,port));
break;
case MsgId.JOIN_GROUP:
String groupId=msg.getData().getString(Router.GROUP_ID);
router.joinGroup(groupId,null,new MyGroupHandler(groupId));
break;
case MsgId.LEAVE_GROUP:
groupId=msg.getData().getString(Router.GROUP_ID);
router.leaveGroup(groupId);
break;
case MsgId.SEND_MSG:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
groupId=data.getString(Router.GROUP_ID);
router.sendMsg(groupId,new DeviceInfo(name,addr,port),msg.getData());
break;
case MsgId.REGISTER_RECEIVER:
mClientMessenger=msg.replyTo;
break;
case MsgId.UNREGISTER_RECEIVER:
mClientMessenger=null;
break;
case MsgId.SET_CONNECTION_INFO:
data=msg.getData();
name=data.getString(Router.DEVICE_NAME);
int liveTime=data.getInt(Router.LIVENESS_TIMEOUT,-1);
int connTime=data.getInt(Router.CONNECT_TIMEOUT,-1);
int searchTime=data.getInt(Router.SEARCH_TIMEOUT,-1);
boolean useSSL=data.getBoolean(Router.USE_SSL,RouterConfig.DEF_USE_SSL);
router.setConnectionInfo(sessionId,name,useSSL,liveTime,connTime,searchTime);
break;
case MsgId.GET_CONNECTION_INFO:
router.getConnectionInfo(sessionId);
break;
case MsgId.GET_DEVICE_INFO:
router.getDeviceInfo(sessionId);
break;
case MsgId.GET_CONNECTED_PEERS:
data=msg.getData();
groupId=null;
if (data != null) groupId=data.getString(Router.GROUP_ID);
router.getConnectedPeers(groupId,sessionId);
break;
case MsgId.GET_NETWORKS:
router.getNetworks(sessionId);
break;
case MsgId.GET_ACTIVE_NETWORK:
router.getActiveNetwork(sessionId);
break;
case MsgId.ACTIVATE_NETWORK:
data=msg.getData();
int type=data.getInt(Router.NET_TYPE);
name=data.getString(Router.NET_NAME);
int encrypt=data.getInt(Router.NET_ENCRYPT);
String pass=data.getString(Router.NET_PASS);
boolean hidden=data.getBoolean(Router.NET_HIDDEN);
byte[] info=data.getByteArray(Router.NET_INFO);
String intfName=data.getString(Router.NET_INTF_NAME);
addr=data.getString(Router.NET_ADDR);
boolean mcast=data.getBoolean(Router.NET_INTF_MCAST);
router.activateNetwork(sessionId,new NetInfo(type,name,encrypt,pass,hidden,info,intfName,addr,mcast));
break;
default :
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MsgId.START_SEARCH:
    Bundle data=msg.getData();
  String name=data.getString(Router.PEER_NAME);
String addr=data.getString(Router.PEER_ADDR);
String port=data.getString(Router.PEER_PORT);
int timeout=data.getInt(Router.SEARCH_TIMEOUT);
router.startPeerSearch(sessionId,new DeviceInfo(name,addr,port),timeout);
break;
case MsgId.STOP_SEARCH:
router.stopPeerSearch(sessionId);
break;
case MsgId.ACCEPT_CONNECTION:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
router.acceptConnection(sessionId,new DeviceInfo(name,addr,port));
break;
case MsgId.DENY_CONNECTION:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
int denyCode=data.getInt(Router.CONN_DENY_CODE);
router.denyConnection(sessionId,new DeviceInfo(name,addr,port),denyCode);
break;
case MsgId.CONNECT:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
byte[] token=data.getByteArray(Router.AUTHENTICATION_TOKEN);
timeout=data.getInt(Router.CONNECT_TIMEOUT);
router.connectPeer(sessionId,new DeviceInfo(name,addr,port),token,timeout);
break;
case MsgId.DISCONNECT:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
router.disconnectPeer(sessionId,new DeviceInfo(name,addr,port));
break;
case MsgId.JOIN_GROUP:
String groupId=msg.getData().getString(Router.GROUP_ID);
router.joinGroup(groupId,null,new MyGroupHandler(groupId));
break;
case MsgId.LEAVE_GROUP:
groupId=msg.getData().getString(Router.GROUP_ID);
router.leaveGroup(groupId);
break;
case MsgId.SEND_MSG:
data=msg.getData();
name=data.getString(Router.PEER_NAME);
addr=data.getString(Router.PEER_ADDR);
port=data.getString(Router.PEER_PORT);
groupId=data.getString(Router.GROUP_ID);
router.sendMsg(groupId,new DeviceInfo(name,addr,port),msg.getData());
break;
case MsgId.REGISTER_RECEIVER:
mClientMessenger=msg.replyTo;
break;
case MsgId.UNREGISTER_RECEIVER:
mClientMessenger=null;
break;
case MsgId.SET_CONNECTION_INFO:
data=msg.getData();
name=data.getString(Router.DEVICE_NAME);
int liveTime=data.getInt(Router.LIVENESS_TIMEOUT,-1);
int connTime=data.getInt(Router.CONNECT_TIMEOUT,-1);
int searchTime=data.getInt(Router.SEARCH_TIMEOUT,-1);
boolean useSSL=data.getBoolean(Router.USE_SSL,RouterConfig.DEF_USE_SSL);
router.setConnectionInfo(sessionId,name,useSSL,liveTime,connTime,searchTime);
break;
case MsgId.GET_CONNECTION_INFO:
router.getConnectionInfo(sessionId);
break;
case MsgId.GET_DEVICE_INFO:
router.getDeviceInfo(sessionId);
break;
case MsgId.GET_CONNECTED_PEERS:
data=msg.getData();
groupId=null;
if (data != null) groupId=data.getString(Router.GROUP_ID);
router.getConnectedPeers(groupId,sessionId);
break;
case MsgId.GET_NETWORKS:
router.getNetworks(sessionId);
break;
case MsgId.GET_ACTIVE_NETWORK:
router.getActiveNetwork(sessionId);
break;
case MsgId.ACTIVATE_NETWORK:
data=msg.getData();
int type=data.getInt(Router.NET_TYPE);
name=data.getString(Router.NET_NAME);
int encrypt=data.getInt(Router.NET_ENCRYPT);
String pass=data.getString(Router.NET_PASS);
boolean hidden=data.getBoolean(Router.NET_HIDDEN);
byte[] info=data.getByteArray(Router.NET_INFO);
String intfName=data.getString(Router.NET_INTF_NAME);
addr=data.getString(Router.NET_ADDR);
boolean mcast=data.getBoolean(Router.NET_INTF_MCAST);
router.activateNetwork(sessionId,new NetInfo(type,name,encrypt,pass,hidden,info,intfName,addr,mcast));
break;
default :
}
}