Program: 32460
Project: 32460
Buggy source:
@Override public void handleMessage(Message msg){
  Bundle bundle=msg.getData();
  if (bundle != null) {
    bundle.setClassLoader(loader);
  }
  if (bundle != null && bundle.containsKey(TransportConstants.ENABLE_LEGACY_MODE_EXTRA)) {
    boolean enableLegacy=bundle.getBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,false);
    Log.d(TAG,"String_Node_Str" + enableLegacy);
    enableLegacyMode(enableLegacy);
  }
switch (msg.what) {
case TransportConstants.ROUTER_REGISTER_CLIENT_RESPONSE:
    if (msg.arg1 == TransportConstants.REGISTRATION_RESPONSE_SUCESS) {
      registeredWithRouterService=true;
      if (bundle != null && bundle.containsKey(TransportConstants.CONNECTED_DEVICE_STRING_EXTRA_NAME)) {
      }
      if (queuedOnTransportConnect != null) {
        onHardwareConnected(queuedOnTransportConnect);
        queuedOnTransportConnect=null;
      }
 else       if (SdlBroadcastReceiver.isTransportConnected(getContext())) {
        onHardwareConnected(null);
      }
    }
 else {
      registeredWithRouterService=false;
      Log.w(TAG,"String_Node_Str" + msg.arg1);
    }
  break;
case TransportConstants.ROUTER_UNREGISTER_CLIENT_RESPONSE:
if (msg.arg1 == TransportConstants.UNREGISTRATION_RESPONSE_SUCESS) {
}
 else {
  Log.w(TAG,"String_Node_Str" + msg.arg1);
}
break;
case TransportConstants.ROUTER_RECEIVED_PACKET:
int flags=bundle.getInt(TransportConstants.BYTES_TO_SEND_FLAGS,TransportConstants.BYTES_TO_SEND_FLAG_NONE);
if (bundle.containsKey(TransportConstants.FORMED_PACKET_EXTRA_NAME)) {
Parcelable packet=bundle.getParcelable(TransportConstants.FORMED_PACKET_EXTRA_NAME);
if (flags == TransportConstants.BYTES_TO_SEND_FLAG_NONE) {
if (packet != null) {
Log.i(TAG,"String_Node_Str" + packet.toString());
onPacketReceived(packet);
}
 else {
Log.w(TAG,"String_Node_Str");
}
}
 else if (flags == TransportConstants.BYTES_TO_SEND_FLAG_SDL_PACKET_INCLUDED) {
Log.i(TAG,"String_Node_Str");
bufferedPacket=(SdlPacket)packet;
if (bufferedPayloadAssembler != null) {
bufferedPayloadAssembler.close();
bufferedPayloadAssembler=null;
}
bufferedPayloadAssembler=new ByteAraryMessageAssembler();
bufferedPayloadAssembler.init();
}
}
 else if (bundle.containsKey(TransportConstants.BYTES_TO_SEND_EXTRA_NAME)) {
if (bufferedPayloadAssembler != null) {
byte[] chunk=bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME);
if (!bufferedPayloadAssembler.handleMessage(flags,chunk)) {
Log.e(TAG,"String_Node_Str");
}
if (bufferedPayloadAssembler.isFinished()) {
bufferedPacket.setPayload(bufferedPayloadAssembler.getBytes());
bufferedPayloadAssembler.close();
bufferedPayloadAssembler=null;
Log.i(TAG,"String_Node_Str" + bufferedPacket.toString());
onPacketReceived(bufferedPacket);
bufferedPacket=null;
}
}
}
 else {
Log.w(TAG,"String_Node_Str");
}
break;
case TransportConstants.HARDWARE_CONNECTION_EVENT:
if (bundle.containsKey(TransportConstants.HARDWARE_DISCONNECTED)) {
Log.d(TAG,"String_Node_Str");
onHardwareDisconnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_DISCONNECTED)));
break;
}
if (bundle.containsKey(TransportConstants.HARDWARE_CONNECTED)) {
onHardwareConnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_CONNECTED)));
break;
}
break;
default :
super.handleMessage(msg);
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  Bundle bundle=msg.getData();
  if (bundle != null) {
    bundle.setClassLoader(loader);
  }
  if (bundle != null && bundle.containsKey(TransportConstants.ENABLE_LEGACY_MODE_EXTRA)) {
    boolean enableLegacy=bundle.getBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,false);
    Log.d(TAG,"String_Node_Str" + enableLegacy);
    enableLegacyMode(enableLegacy);
  }
switch (msg.what) {
case TransportConstants.ROUTER_REGISTER_CLIENT_RESPONSE:
switch (msg.arg1) {
case TransportConstants.REGISTRATION_RESPONSE_SUCESS:
      registeredWithRouterService=true;
    if (bundle != null && bundle.containsKey(TransportConstants.CONNECTED_DEVICE_STRING_EXTRA_NAME)) {
    }
  if (queuedOnTransportConnect != null) {
    onHardwareConnected(queuedOnTransportConnect);
    queuedOnTransportConnect=null;
  }
 else   if (SdlBroadcastReceiver.isTransportConnected(getContext())) {
    onHardwareConnected(null);
  }
break;
case TransportConstants.REGISTRATION_RESPONSE_DENIED_LEGACY_MODE_ENABLED:
Log.d(TAG,"String_Node_Str");
registeredWithRouterService=false;
enableLegacyMode(true);
onFailedRouterRegistration(msg.arg1);
break;
default :
registeredWithRouterService=false;
Log.w(TAG,"String_Node_Str" + msg.arg1);
break;
}
;
break;
case TransportConstants.ROUTER_UNREGISTER_CLIENT_RESPONSE:
if (msg.arg1 == TransportConstants.UNREGISTRATION_RESPONSE_SUCESS) {
}
 else {
Log.w(TAG,"String_Node_Str" + msg.arg1);
}
break;
case TransportConstants.ROUTER_RECEIVED_PACKET:
int flags=bundle.getInt(TransportConstants.BYTES_TO_SEND_FLAGS,TransportConstants.BYTES_TO_SEND_FLAG_NONE);
if (bundle.containsKey(TransportConstants.FORMED_PACKET_EXTRA_NAME)) {
Parcelable packet=bundle.getParcelable(TransportConstants.FORMED_PACKET_EXTRA_NAME);
if (flags == TransportConstants.BYTES_TO_SEND_FLAG_NONE) {
if (packet != null) {
Log.i(TAG,"String_Node_Str" + packet.toString());
onPacketReceived(packet);
}
 else {
Log.w(TAG,"String_Node_Str");
}
}
 else if (flags == TransportConstants.BYTES_TO_SEND_FLAG_SDL_PACKET_INCLUDED) {
Log.i(TAG,"String_Node_Str");
bufferedPacket=(SdlPacket)packet;
if (bufferedPayloadAssembler != null) {
bufferedPayloadAssembler.close();
bufferedPayloadAssembler=null;
}
bufferedPayloadAssembler=new ByteAraryMessageAssembler();
bufferedPayloadAssembler.init();
}
}
 else if (bundle.containsKey(TransportConstants.BYTES_TO_SEND_EXTRA_NAME)) {
if (bufferedPayloadAssembler != null) {
byte[] chunk=bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME);
if (!bufferedPayloadAssembler.handleMessage(flags,chunk)) {
Log.e(TAG,"String_Node_Str");
}
if (bufferedPayloadAssembler.isFinished()) {
bufferedPacket.setPayload(bufferedPayloadAssembler.getBytes());
bufferedPayloadAssembler.close();
bufferedPayloadAssembler=null;
Log.i(TAG,"String_Node_Str" + bufferedPacket.toString());
onPacketReceived(bufferedPacket);
bufferedPacket=null;
}
}
}
 else {
Log.w(TAG,"String_Node_Str");
}
break;
case TransportConstants.HARDWARE_CONNECTION_EVENT:
if (bundle.containsKey(TransportConstants.HARDWARE_DISCONNECTED)) {
Log.d(TAG,"String_Node_Str");
onHardwareDisconnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_DISCONNECTED)));
break;
}
if (bundle.containsKey(TransportConstants.HARDWARE_CONNECTED)) {
onHardwareConnected(TransportType.valueOf(bundle.getString(TransportConstants.HARDWARE_CONNECTED)));
break;
}
break;
default :
super.handleMessage(msg);
}
}