Program: 19738
Project: 19738
Buggy source:
/** 
 * Get a composite senone sequence given the unit The unit should have a LeftRightContext, where one or two of 'left' or 'right' may be null to indicate that the match should succeed on any context.
 * @param unit the unit
 */
public SenoneSequence getCompositeSenoneSequence(Unit unit,HMMPosition position){
  Context context=unit.getContext();
  SenoneSequence compositeSenoneSequence=null;
  compositeSenoneSequence=(SenoneSequence)compositeSenoneSequenceCache.get(unit.toString());
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("String_Node_Str" + unit.toString() + ((compositeSenoneSequence != null) ? "String_Node_Str" : "String_Node_Str"));
  }
  if (compositeSenoneSequence != null) {
    return compositeSenoneSequence;
  }
  List senoneSequenceList=new ArrayList();
  for (Iterator i=getHMMIterator(); i.hasNext(); ) {
    SenoneHMM hmm=(SenoneHMM)i.next();
    if (hmm.getPosition() == position) {
      Unit hmmUnit=hmm.getUnit();
      if (hmmUnit.isPartialMatch(unit.getName(),context)) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("String_Node_Str" + hmm.getUnit().toString());
        }
        senoneSequenceList.add(hmm.getSenoneSequence());
      }
    }
  }
  if (senoneSequenceList.size() == 0) {
    Unit ciUnit=unitManager.getUnit(unit.getName(),unit.isFiller());
    SenoneHMM baseHMM=lookupHMM(ciUnit,HMMPosition.UNDEFINED);
    senoneSequenceList.add(baseHMM.getSenoneSequence());
  }
  int longestSequence=0;
  for (int i=0; i < senoneSequenceList.size(); i++) {
    SenoneSequence ss=(SenoneSequence)senoneSequenceList.get(i);
    if (ss.getSenones().length > longestSequence) {
      longestSequence=ss.getSenones().length;
    }
  }
  List compositeSenones=new ArrayList();
  float logWeight=0.0f;
  for (int i=0; i < longestSequence; i++) {
    Set compositeSenoneSet=new HashSet();
    for (int j=0; j < senoneSequenceList.size(); j++) {
      SenoneSequence senoneSequence=(SenoneSequence)senoneSequenceList.get(j);
      if (i < senoneSequence.getSenones().length) {
        Senone senone=senoneSequence.getSenones()[i];
        compositeSenoneSet.add(senone);
      }
    }
    compositeSenones.add(CompositeSenone.create(compositeSenoneSet,logWeight));
  }
  compositeSenoneSequence=SenoneSequence.create(compositeSenones);
  compositeSenoneSequenceCache.put(unit.toString(),compositeSenoneSequence);
  if (logger.isLoggable(Level.FINE)) {
    logger.fine(unit.toString() + "String_Node_Str" + compositeSenones.size()+ "String_Node_Str");
    if (logger.isLoggable(Level.FINEST)) {
      compositeSenoneSequence.dump("String_Node_Str");
    }
  }
  return compositeSenoneSequence;
}

Fixed version (ground truth):
/** 
 * Get a composite senone sequence given the unit The unit should have a LeftRightContext, where one or two of 'left' or 'right' may be null to indicate that the match should succeed on any context.
 * @param unit the unit
 */
public SenoneSequence getCompositeSenoneSequence(Unit unit,HMMPosition position){
  Context context=unit.getContext();
  SenoneSequence compositeSenoneSequence=null;
  compositeSenoneSequence=compositeSenoneSequenceCache.get(unit.toString());
  if (logger.isLoggable(Level.FINE)) {
    logger.fine("String_Node_Str" + unit.toString() + ((compositeSenoneSequence != null) ? "String_Node_Str" : "String_Node_Str"));
  }
  if (compositeSenoneSequence != null) {
    return compositeSenoneSequence;
  }
  List<SenoneSequence> senoneSequenceList=new ArrayList<SenoneSequence>();
  for (Iterator i=getHMMIterator(); i.hasNext(); ) {
    SenoneHMM hmm=(SenoneHMM)i.next();
    if (hmm.getPosition() == position) {
      Unit hmmUnit=hmm.getUnit();
      if (hmmUnit.isPartialMatch(unit.getName(),context)) {
        if (logger.isLoggable(Level.FINE)) {
          logger.fine("String_Node_Str" + hmm.getUnit().toString());
        }
        senoneSequenceList.add(hmm.getSenoneSequence());
      }
    }
  }
  if (senoneSequenceList.size() == 0) {
    Unit ciUnit=unitManager.getUnit(unit.getName(),unit.isFiller());
    SenoneHMM baseHMM=lookupHMM(ciUnit,HMMPosition.UNDEFINED);
    senoneSequenceList.add(baseHMM.getSenoneSequence());
  }
  int longestSequence=0;
  for (int i=0; i < senoneSequenceList.size(); i++) {
    SenoneSequence ss=senoneSequenceList.get(i);
    if (ss.getSenones().length > longestSequence) {
      longestSequence=ss.getSenones().length;
    }
  }
  List<CompositeSenone> compositeSenones=new ArrayList<CompositeSenone>();
  float logWeight=0.0f;
  for (int i=0; i < longestSequence; i++) {
    Set<Senone> compositeSenoneSet=new HashSet<Senone>();
    for (int j=0; j < senoneSequenceList.size(); j++) {
      SenoneSequence senoneSequence=senoneSequenceList.get(j);
      if (i < senoneSequence.getSenones().length) {
        Senone senone=senoneSequence.getSenones()[i];
        compositeSenoneSet.add(senone);
      }
    }
    compositeSenones.add(CompositeSenone.create(compositeSenoneSet,logWeight));
  }
  compositeSenoneSequence=SenoneSequence.create(compositeSenones);
  compositeSenoneSequenceCache.put(unit.toString(),compositeSenoneSequence);
  if (logger.isLoggable(Level.FINE)) {
    logger.fine(unit.toString() + "String_Node_Str" + compositeSenones.size()+ "String_Node_Str");
    if (logger.isLoggable(Level.FINEST)) {
      compositeSenoneSequence.dump("String_Node_Str");
    }
  }
  return compositeSenoneSequence;
}