Program: 176859
Project: 176859
Buggy source:
/** 
 * Gets the enclosing document name.
 * @param m the m
 * @param criteria Input criteria
 * @param viaColumnName true if <code>criteria</code> is column Name, false if <code>criteria</code> is column field name
 * @return the enclosing document name
 */
public static String getEnclosingEmbeddedFieldName(EntityMetadata m,String criteria,boolean viaColumnName){
  String enclosingEmbeddedFieldName=null;
  StringTokenizer strToken=new StringTokenizer(criteria,"String_Node_Str");
  String embeddedFieldName=null;
  String embeddableAttributeName=null;
  while (strToken.hasMoreElements()) {
    embeddableAttributeName=strToken.nextToken();
    if (strToken.countTokens() > 1) {
      embeddedFieldName=strToken.nextToken();
    }
  }
  Metamodel metaModel=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  try {
    Attribute attribute=entity.getAttribute(embeddableAttributeName);
    if (((MetamodelImpl)metaModel).isEmbeddable(((AbstractAttribute)attribute).getBindableJavaType())) {
      EmbeddableType embeddable=metaModel.embeddable(((AbstractAttribute)attribute).getBindableJavaType());
      Iterator<Attribute> iter=embeddable.getAttributes().iterator();
      while (iter.hasNext()) {
        AbstractAttribute attrib=(AbstractAttribute)iter.next();
        if (viaColumnName && attrib.getName().equals(embeddedFieldName)) {
          enclosingEmbeddedFieldName=attribute.getName();
          break;
        }
        if (!viaColumnName && attrib.getJPAColumnName().equals(embeddedFieldName)) {
          enclosingEmbeddedFieldName=attribute.getName();
          break;
        }
      }
    }
  }
 catch (  IllegalArgumentException iax) {
    return null;
  }
  return enclosingEmbeddedFieldName;
}

Fixed version (ground truth):
/** 
 * Gets the enclosing document name.
 * @param m the m
 * @param criteria Input criteria
 * @param viaColumnName true if <code>criteria</code> is column Name, false if <code>criteria</code> is column field name
 * @return the enclosing document name
 */
public static String getEnclosingEmbeddedFieldName(EntityMetadata m,String criteria,boolean viaColumnName){
  String enclosingEmbeddedFieldName=null;
  StringTokenizer strToken=new StringTokenizer(criteria,"String_Node_Str");
  String embeddedFieldName=null;
  String embeddableAttributeName=null;
  while (strToken.hasMoreElements()) {
    embeddableAttributeName=strToken.nextToken();
    if (strToken.countTokens() > 0) {
      embeddedFieldName=strToken.nextToken();
    }
  }
  Metamodel metaModel=KunderaMetadata.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
  EntityType entity=metaModel.entity(m.getEntityClazz());
  try {
    Attribute attribute=entity.getAttribute(embeddableAttributeName);
    if (((MetamodelImpl)metaModel).isEmbeddable(((AbstractAttribute)attribute).getBindableJavaType())) {
      EmbeddableType embeddable=metaModel.embeddable(((AbstractAttribute)attribute).getBindableJavaType());
      Iterator<Attribute> iter=embeddable.getAttributes().iterator();
      while (iter.hasNext()) {
        AbstractAttribute attrib=(AbstractAttribute)iter.next();
        if (viaColumnName && attrib.getName().equals(embeddedFieldName)) {
          enclosingEmbeddedFieldName=attribute.getName();
          break;
        }
        if (!viaColumnName && attrib.getJPAColumnName().equals(embeddedFieldName)) {
          enclosingEmbeddedFieldName=attribute.getName();
          break;
        }
      }
    }
  }
 catch (  IllegalArgumentException iax) {
    return null;
  }
  return enclosingEmbeddedFieldName;
}