Program: 155960
Project: 155960
Buggy source:
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(1);
  String id=ChannelBuffers.hexDump(buf.readBytes(6));
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,id);
  if (deviceSession == null) {
    return null;
  }
  int type=buf.readUnsignedShort();
  buf.readUnsignedShort();
  if (type == 0x2086 || type == 0x2084 || type == 0x2082) {
    Position position=new Position(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    buf.readUnsignedByte();
    buf.readUnsignedShort();
    position.setTime(decodeDate(buf));
    position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf,8)));
    position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf,9)));
    int flags=buf.readUnsignedByte();
    position.setValid(BitUtil.check(flags,0));
    if (!BitUtil.check(flags,1)) {
      position.setLatitude(-position.getLatitude());
    }
    if (!BitUtil.check(flags,1)) {
      position.setLongitude(-position.getLongitude());
    }
    position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
    position.setCourse(buf.readUnsignedByte() * 2);
    position.set(Position.KEY_SATELLITES,buf.readUnsignedByte());
    position.set(Position.KEY_RSSI,buf.readUnsignedByte());
    position.set(Position.KEY_ODOMETER,buf.readUnsignedInt() * 1000);
    position.set(Position.KEY_STATUS,buf.readUnsignedInt());
    return position;
  }
 else   if (type == 0x3088) {
    Position position=new Position(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    getLastLocation(position,null);
    buf.readUnsignedShort();
    buf.skipBytes(8);
    buf.skipBytes(8);
    position.set("String_Node_Str",decodeDate(buf).getTime());
    position.set("String_Node_Str",decodeDate(buf).getTime());
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set(Position.KEY_FUEL_CONSUMPTION,buf.readUnsignedInt());
    position.set(Position.KEY_ODOMETER_TRIP,buf.readUnsignedInt());
    position.set("String_Node_Str",UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedByte() - 40);
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    for (    String speedType : Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      position.set(speedType + "String_Node_Str",buf.readUnsignedShort());
      position.set(speedType + "String_Node_Str",buf.readUnsignedInt());
      position.set(speedType + "String_Node_Str",buf.readUnsignedInt());
    }
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedInt());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    return position;
  }
  return null;
}

Fixed version (ground truth):
@Override protected Object decode(Channel channel,SocketAddress remoteAddress,Object msg) throws Exception {
  ChannelBuffer buf=(ChannelBuffer)msg;
  buf.skipBytes(1);
  String id=ChannelBuffers.hexDump(buf.readBytes(6));
  DeviceSession deviceSession=getDeviceSession(channel,remoteAddress,id);
  if (deviceSession == null) {
    return null;
  }
  int type=buf.readUnsignedShort();
  buf.readUnsignedShort();
  if (type == 0x2086 || type == 0x2084 || type == 0x2082) {
    Position position=new Position(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    buf.readUnsignedByte();
    buf.readUnsignedShort();
    position.setTime(decodeDate(buf));
    position.setLatitude(decodeCoordinate(BcdUtil.readInteger(buf,8)));
    position.setLongitude(decodeCoordinate(BcdUtil.readInteger(buf,9)));
    int flags=buf.readUnsignedByte();
    position.setValid(BitUtil.check(flags,0));
    if (!BitUtil.check(flags,1)) {
      position.setLatitude(-position.getLatitude());
    }
    if (!BitUtil.check(flags,2)) {
      position.setLongitude(-position.getLongitude());
    }
    position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
    position.setCourse(buf.readUnsignedByte() * 2);
    position.set(Position.KEY_SATELLITES,buf.readUnsignedByte());
    position.set(Position.KEY_RSSI,buf.readUnsignedByte());
    position.set(Position.KEY_ODOMETER,buf.readUnsignedInt() * 1000);
    position.set(Position.KEY_STATUS,buf.readUnsignedInt());
    return position;
  }
 else   if (type == 0x3088) {
    Position position=new Position(getProtocolName());
    position.setDeviceId(deviceSession.getDeviceId());
    getLastLocation(position,null);
    buf.readUnsignedShort();
    buf.skipBytes(8);
    buf.skipBytes(8);
    position.set("String_Node_Str",decodeDate(buf).getTime());
    position.set("String_Node_Str",decodeDate(buf).getTime());
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set(Position.KEY_FUEL_CONSUMPTION,buf.readUnsignedInt());
    position.set(Position.KEY_ODOMETER_TRIP,buf.readUnsignedInt());
    position.set("String_Node_Str",UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedByte() - 40);
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    for (    String speedType : Arrays.asList("String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str")) {
      position.set(speedType + "String_Node_Str",buf.readUnsignedShort());
      position.set(speedType + "String_Node_Str",buf.readUnsignedInt());
      position.set(speedType + "String_Node_Str",buf.readUnsignedInt());
    }
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedInt());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedShort());
    position.set("String_Node_Str",buf.readUnsignedByte());
    position.set("String_Node_Str",buf.readUnsignedByte());
    return position;
  }
  return null;
}