Program: 93754
Project: 93754
Buggy source:
/** 
 * @description match search string with pinyinUnits,if success,save theChinese keywords.
 * @param pinyinUnits pinyinUnits head node index
 * @param pinyinUnitIndex pinyinUint Index
 * @param qwertyPinyinUnitIndex pinyinBaseUnit Index
 * @param baseData base data for search.
 * @param searchBuffer search keyword.
 * @param chineseKeyWord save the Chinese keyword.
 * @return true if find,false otherwise.
 */
private static boolean findPinyinUnits(final List<PinyinUnit> pinyinUnits,int pinyinUnitIndex,int qwertyPinyinUnitIndex,final String baseData,StringBuffer searchBuffer,StringBuffer chineseKeyWord){
  if ((null == pinyinUnits) || (null == baseData) || (null == searchBuffer)|| (null == chineseKeyWord)) {
    return false;
  }
  String search=searchBuffer.toString();
  if (search.length() <= 0) {
    return true;
  }
  if (pinyinUnitIndex >= pinyinUnits.size()) {
    return false;
  }
  PinyinUnit pyUnit=pinyinUnits.get(pinyinUnitIndex);
  if (qwertyPinyinUnitIndex >= pyUnit.getPinyinBaseUnitIndex().size()) {
    return false;
  }
  PinyinBaseUnit pinyinBaseUnit=pyUnit.getPinyinBaseUnitIndex().get(qwertyPinyinUnitIndex);
  if (pyUnit.isPinyin()) {
    if (search.startsWith(String.valueOf(pinyinBaseUnit.getPinyin().charAt(0)))) {
      searchBuffer.delete(0,1);
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin().charAt(0));
        chineseKeyWord.deleteCharAt(chineseKeyWord.length() - 1);
      }
    }
    if (pinyinBaseUnit.getPinyin().startsWith(search)) {
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      searchBuffer.delete(0,searchBuffer.length());
      return true;
    }
 else     if (search.startsWith(pinyinBaseUnit.getPinyin())) {
      searchBuffer.delete(0,pinyinBaseUnit.getPinyin().length());
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin());
        chineseKeyWord.deleteCharAt(chineseKeyWord.length() - 1);
      }
    }
 else {
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
      if (found == true) {
        return true;
      }
    }
  }
 else {
    if (pinyinBaseUnit.getPinyin().startsWith(search)) {
      int startIndex=0;
      chineseKeyWord.append(baseData.substring(startIndex + pyUnit.getStartPosition(),startIndex + pyUnit.getStartPosition() + search.length()));
      searchBuffer.delete(0,searchBuffer.length());
      return true;
    }
 else     if (search.startsWith(pinyinBaseUnit.getPinyin())) {
      int startIndex=0;
      searchBuffer.delete(0,pinyinBaseUnit.getPinyin().length());
      chineseKeyWord.append(baseData.substring(startIndex + pyUnit.getStartPosition(),startIndex + pyUnit.getStartPosition() + pinyinBaseUnit.getPinyin().length()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin());
        chineseKeyWord.delete(chineseKeyWord.length() - pinyinBaseUnit.getPinyin().length(),chineseKeyWord.length());
      }
    }
 else     if ((chineseKeyWord.length() <= 0)) {
      if (pinyinBaseUnit.getPinyin().contains(search)) {
        int index=pinyinBaseUnit.getPinyin().indexOf(search);
        chineseKeyWord.append(baseData.substring(index + pyUnit.getStartPosition(),index + pyUnit.getStartPosition() + search.length()));
        searchBuffer.delete(0,searchBuffer.length());
        return true;
      }
 else {
        int numLength=pinyinBaseUnit.getPinyin().length();
        for (int i=0; i < numLength; i++) {
          String subStr=pinyinBaseUnit.getPinyin().substring(i);
          if (search.startsWith(subStr)) {
            searchBuffer.delete(0,subStr.length());
            chineseKeyWord.append(baseData.substring(i + pyUnit.getStartPosition(),i + pyUnit.getStartPosition() + subStr.length()));
            boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
            if (true == found) {
              return true;
            }
 else {
              searchBuffer.insert(0,pinyinBaseUnit.getPinyin().substring(i));
              chineseKeyWord.delete(chineseKeyWord.length() - subStr.length(),chineseKeyWord.length());
            }
          }
        }
        boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
        if (true == found) {
          return true;
        }
      }
    }
 else {
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * @description match search string with pinyinUnits,if success,save the Chinese keywords.
 * @param pinyinUnits    		pinyinUnits head node index
 * @param pinyinUnitIndex		pinyinUint Index
 * @param qwertyPinyinUnitIndex	pinyinBaseUnit Index
 * @param baseData				base data for search.
 * @param searchBuffer			search keyword.
 * @param chineseKeyWord		save the Chinese keyword.
 * @return true if find,false otherwise.
 */
private static boolean findPinyinUnits(final List<PinyinUnit> pinyinUnits,int pinyinUnitIndex,int qwertyPinyinUnitIndex,final String baseData,StringBuffer searchBuffer,StringBuffer chineseKeyWord){
  if ((null == pinyinUnits) || (null == baseData) || (null == searchBuffer)|| (null == chineseKeyWord)) {
    return false;
  }
  String search=searchBuffer.toString();
  if (search.length() <= 0) {
    return true;
  }
  if (pinyinUnitIndex >= pinyinUnits.size()) {
    return false;
  }
  PinyinUnit pyUnit=pinyinUnits.get(pinyinUnitIndex);
  if (qwertyPinyinUnitIndex >= pyUnit.getPinyinBaseUnitIndex().size()) {
    return false;
  }
  PinyinBaseUnit pinyinBaseUnit=pyUnit.getPinyinBaseUnitIndex().get(qwertyPinyinUnitIndex);
  if (pyUnit.isPinyin()) {
    if (search.startsWith(String.valueOf(pinyinBaseUnit.getPinyin().charAt(0)))) {
      searchBuffer.delete(0,1);
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin().charAt(0));
        chineseKeyWord.deleteCharAt(chineseKeyWord.length() - 1);
      }
    }
    if (pinyinBaseUnit.getPinyin().startsWith(search)) {
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      searchBuffer.delete(0,searchBuffer.length());
      return true;
    }
 else     if (search.startsWith(pinyinBaseUnit.getPinyin())) {
      searchBuffer.delete(0,pinyinBaseUnit.getPinyin().length());
      chineseKeyWord.append(baseData.charAt(pyUnit.getStartPosition()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin());
        chineseKeyWord.deleteCharAt(chineseKeyWord.length() - 1);
      }
    }
 else {
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
      if (found == true) {
        return true;
      }
    }
  }
 else {
    if (pinyinBaseUnit.getPinyin().startsWith(search)) {
      int startIndex=0;
      chineseKeyWord.append(baseData.substring(startIndex + pyUnit.getStartPosition(),startIndex + pyUnit.getStartPosition() + search.length()));
      searchBuffer.delete(0,searchBuffer.length());
      return true;
    }
 else     if (search.startsWith(pinyinBaseUnit.getPinyin())) {
      int startIndex=0;
      searchBuffer.delete(0,pinyinBaseUnit.getPinyin().length());
      chineseKeyWord.append(baseData.substring(startIndex + pyUnit.getStartPosition(),startIndex + pyUnit.getStartPosition() + pinyinBaseUnit.getPinyin().length()));
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
 else {
        searchBuffer.insert(0,pinyinBaseUnit.getPinyin());
        chineseKeyWord.delete(chineseKeyWord.length() - pinyinBaseUnit.getPinyin().length(),chineseKeyWord.length());
      }
    }
 else     if ((chineseKeyWord.length() <= 0)) {
      if (pinyinBaseUnit.getPinyin().contains(search)) {
        int index=pinyinBaseUnit.getPinyin().indexOf(search);
        chineseKeyWord.append(baseData.substring(index + pyUnit.getStartPosition(),index + pyUnit.getStartPosition() + search.length()));
        searchBuffer.delete(0,searchBuffer.length());
        return true;
      }
 else {
        int numLength=pinyinBaseUnit.getPinyin().length();
        for (int i=0; i < numLength; i++) {
          String subStr=pinyinBaseUnit.getPinyin().substring(i);
          if (search.startsWith(subStr)) {
            searchBuffer.delete(0,subStr.length());
            chineseKeyWord.append(baseData.substring(i + pyUnit.getStartPosition(),i + pyUnit.getStartPosition() + subStr.length()));
            boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex + 1,0,baseData,searchBuffer,chineseKeyWord);
            if (true == found) {
              return true;
            }
 else {
              searchBuffer.insert(0,pinyinBaseUnit.getPinyin().substring(i));
              chineseKeyWord.delete(chineseKeyWord.length() - subStr.length(),chineseKeyWord.length());
            }
          }
        }
        boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
        if (true == found) {
          return true;
        }
      }
    }
 else {
      boolean found=findPinyinUnits(pinyinUnits,pinyinUnitIndex,qwertyPinyinUnitIndex + 1,baseData,searchBuffer,chineseKeyWord);
      if (true == found) {
        return true;
      }
    }
  }
  return false;
}