Program: 172373
Project: 172373
Buggy source:
/** 
 * 提升品质
 * @param playerId
 */
public Int2Param improveQuality(int playerId,int petId){
  Int2Param cli=new Int2Param();
  PetBag bag=getPetBag(playerId);
  Pet pet=bag.getPetMap().get(petId);
  if (pet == null) {
    cli.param1=Response.PET_NOT_EXIST;
    return cli;
  }
  PetConfig petConfig=ConfigData.getConfig(PetConfig.class,petId);
  Integer currentCount=bag.getMaterialMap().get(petConfig.materialId);
  if (currentCount == null) {
    currentCount=0;
  }
  if (currentCount < petConfig.nextQualityMaterialCount) {
    cli.param1=Response.PET_MATERIAL_NOT_ENOUGH;
    return cli;
  }
  if (petConfig.nextQualityId == 0) {
    cli.param1=Response.ERR_PARAM;
    return cli;
  }
  List<GoodsEntry> costs=Lists.newArrayList();
  for (int i=0; i < petConfig.nextQualityCost.length; i+=2) {
    GoodsEntry e=new GoodsEntry(petConfig.nextQualityCost[i],petConfig.nextQualityCost[i + 1]);
    costs.add(e);
  }
  int ret=goodsService.decConsume(playerId,costs,LogConsume.PET_IMPROVE);
  if (Response.SUCCESS != ret) {
    cli.param1=ret;
    return cli;
  }
  bag.getPetMap().remove(petId);
  List<Pet> addPets=Lists.newArrayList();
  List<Int2Param> updateIds=Lists.newArrayList();
  if (bag.getPetMap().containsKey(petConfig.nextQualityId)) {
    PetConfig newPetConfig=ConfigData.getConfig(PetConfig.class,petConfig.nextQualityId);
    samePetDecompose(bag,newPetConfig,updateIds);
    cli.param2=1;
  }
 else {
    Pet newPet=new Pet();
    newPet.setId(petConfig.nextQualityId);
    newPet.setSkillID(petConfig.activeSkillId);
    newPet.setPassiveSkillId(pet.getPassiveSkillId() + 1);
    bag.getPetMap().put(newPet.getId(),newPet);
    bag.getMaterialMap().put(petConfig.materialId,currentCount - petConfig.nextQualityMaterialCount);
    if (currentCount == petConfig.nextQualityMaterialCount) {
      bag.getMaterialMap().remove(petConfig.materialId);
    }
    addPets.add(newPet);
  }
  Int2Param delId=new Int2Param();
  delId.param1=petConfig.materialId;
  delId.param2=currentCount - petConfig.nextQualityMaterialCount;
  updateIds.add(delId);
  delId=new Int2Param();
  delId.param1=petId;
  delId.param2=0;
  updateIds.add(delId);
  pushUpdateBag(playerId,addPets,updateIds);
  cli.param1=Response.SUCCESS;
  SessionManager.getInstance().sendMsg(CMD_IMPROVE,cli,playerId);
  if (bag.getFightPetId() == petId) {
    Int2Param vo=toFight(playerId,petConfig.nextQualityId);
    SessionManager.getInstance().sendMsg(CMD_TO_FIGHT,vo,playerId);
  }
  return null;
}

Fixed version (ground truth):
/** 
 * 提升品质
 * @param playerId
 */
public Int2Param improveQuality(int playerId,int petId){
  Int2Param cli=new Int2Param();
  PetBag bag=getPetBag(playerId);
  Pet pet=bag.getPetMap().get(petId);
  if (pet == null) {
    cli.param1=Response.PET_NOT_EXIST;
    return cli;
  }
  PetConfig petConfig=ConfigData.getConfig(PetConfig.class,petId);
  Integer currentCount=bag.getMaterialMap().get(petConfig.materialId);
  if (currentCount == null) {
    currentCount=0;
  }
  if (currentCount < petConfig.nextQualityMaterialCount) {
    cli.param1=Response.PET_MATERIAL_NOT_ENOUGH;
    return cli;
  }
  if (petConfig.nextQualityId == 0) {
    cli.param1=Response.ERR_PARAM;
    return cli;
  }
  List<GoodsEntry> costs=Lists.newArrayList();
  for (int i=0; i < petConfig.nextQualityCost.length; i+=2) {
    GoodsEntry e=new GoodsEntry(petConfig.nextQualityCost[i],petConfig.nextQualityCost[i + 1]);
    costs.add(e);
  }
  int ret=goodsService.decConsume(playerId,costs,LogConsume.PET_IMPROVE);
  if (Response.SUCCESS != ret) {
    cli.param1=ret;
    return cli;
  }
  bag.getPetMap().remove(petId);
  List<Pet> addPets=Lists.newArrayList();
  List<Int2Param> updateIds=Lists.newArrayList();
  if (bag.getPetMap().containsKey(petConfig.nextQualityId)) {
    PetConfig newPetConfig=ConfigData.getConfig(PetConfig.class,petConfig.nextQualityId);
    samePetDecompose(bag,newPetConfig,updateIds);
    cli.param2=1;
  }
 else {
    Pet newPet=new Pet();
    newPet.setId(petConfig.nextQualityId);
    newPet.setSkillID(petConfig.activeSkillId);
    if (newPet.getPassiveSkillId() != 0) {
      newPet.setPassiveSkillId(pet.getPassiveSkillId() + 1);
    }
    bag.getPetMap().put(newPet.getId(),newPet);
    bag.getMaterialMap().put(petConfig.materialId,currentCount - petConfig.nextQualityMaterialCount);
    if (currentCount == petConfig.nextQualityMaterialCount) {
      bag.getMaterialMap().remove(petConfig.materialId);
    }
    addPets.add(newPet);
  }
  Int2Param delId=new Int2Param();
  delId.param1=petConfig.materialId;
  delId.param2=currentCount - petConfig.nextQualityMaterialCount;
  updateIds.add(delId);
  delId=new Int2Param();
  delId.param1=petId;
  delId.param2=0;
  updateIds.add(delId);
  pushUpdateBag(playerId,addPets,updateIds);
  cli.param1=Response.SUCCESS;
  SessionManager.getInstance().sendMsg(CMD_IMPROVE,cli,playerId);
  if (bag.getFightPetId() == petId) {
    Int2Param vo=toFight(playerId,petConfig.nextQualityId);
    SessionManager.getInstance().sendMsg(CMD_TO_FIGHT,vo,playerId);
  }
  return null;
}