nus-yam/ex-repair huggingface dataset:
Program: 18083
Project: 18083
Buggy source:
@Override public void addJPAEdmAssociationView(JPAEdmAssociationView associationView){
  consistentAssociatonList.add(associationView.getEdmAssociation());
}

Fixed version (ground truth):
@Override public void addJPAEdmAssociationView(JPAEdmAssociationView associationView){
  currentAssociation=associationView.getEdmAssociation();
  consistentAssociatonList.add(currentAssociation);
}
Program: 18084
Project: 18084
Buggy source:
@Override public void build() throws ODataJPAModelException {
  Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes=metaModel.getEntities();
  if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true)   return;
 else   if (consistentEntityTypes == null) {
    consistentEntityTypes=new ArrayList<EntityType>();
  }
  for (  javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
    currentEdmEntityType=new EntityType();
    currentJPAEntityType=jpaEntityType;
    JPAEdmNameBuilder.build(JPAEdmEntityType.this);
    JPAEdmPropertyView propertyView=new JPAEdmProperty(schemaView);
    propertyView.getBuilder().build();
    currentEdmEntityType.setProperties(propertyView.getPropertyList());
    JPAEdmKeyView keyView=propertyView.getJPAEdmKeyView();
    currentEdmEntityType.setKey(keyView.getEdmKey());
    consistentEntityTypes.add(currentEdmEntityType);
  }
}

Fixed version (ground truth):
@Override public void build() throws ODataJPAModelException {
  Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes=metaModel.getEntities();
  if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true)   return;
 else   if (consistentEntityTypes == null) {
    consistentEntityTypes=new ArrayList<EntityType>();
  }
  for (  javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
    currentEdmEntityType=new EntityType();
    currentJPAEntityType=jpaEntityType;
    JPAEdmNameBuilder.build(JPAEdmEntityType.this);
    JPAEdmPropertyView propertyView=new JPAEdmProperty(schemaView);
    propertyView.getBuilder().build();
    currentEdmEntityType.setProperties(propertyView.getPropertyList());
    if (propertyView.getJPAEdmNavigationPropertyView() != null) {
      JPAEdmNavigationPropertyView navPropView=propertyView.getJPAEdmNavigationPropertyView();
      if (navPropView.getConsistentEdmNavigationProperties() != null && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
        currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
      }
    }
    JPAEdmKeyView keyView=propertyView.getJPAEdmKeyView();
    currentEdmEntityType.setKey(keyView.getEdmKey());
    consistentEntityTypes.add(currentEdmEntityType);
  }
}
Program: 18085
Project: 18085
Buggy source:
@Override public void build() throws ODataJPAModelException {
  NavigationProperty navigationProperty=new NavigationProperty();
  JPAEdmEntityTypeView entityTypeView=schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
  EntityType<?> jpaEntityType=entityTypeView.getJPAEntityType();
  for (  Attribute<?,?> attribute : jpaEntityType.getAttributes()) {
    PersistentAttributeType attributeType=attribute.getPersistentAttributeType();
switch (attributeType) {
case MANY_TO_MANY:
      break;
case ONE_TO_MANY:
    break;
case MANY_TO_ONE:
  break;
case ONE_TO_ONE:
break;
default :
break;
}
}
}

Fixed version (ground truth):
@Override public void build() throws ODataJPAModelException {
  currentNavigationProperty=new NavigationProperty();
  JPAEdmNameBuilder.build(associationView,propertyView,JPAEdmNavigationProperty.this);
}
Program: 18086
Project: 18086
Buggy source:
public JPAEdmNavigationProperty(JPAEdmSchemaView view){
  super(view);
  this.schemaView=view;
}

Fixed version (ground truth):
public JPAEdmNavigationProperty(JPAEdmSchemaView schemaView){
  super(schemaView);
  consistentNavigationProperties=new ArrayList<NavigationProperty>();
}
Program: 18088
Project: 18088
Buggy source:
@Test public void testGetJPAEdmBuilder(){
  ODataJPAFactoryImpl factory=new ODataJPAFactoryImpl();
  JPAEdmBuilder builder=factory.getJPAAccessFactory().getJPAEdmBuilder(odataJpaContext);
  assertEquals(JPAEdmBuilderV2.class,builder.getClass());
}

Fixed version (ground truth):
@Test public void testGetJPAEdmBuilder(){
  ODataJPAFactoryImpl factory=new ODataJPAFactoryImpl();
}
Program: 18089
Project: 18089
Buggy source:
public static JPAEdmBuilder mockjpaEdmBuilder() throws ODataJPAModelException {
  JPAEdmBuilder builder=EasyMock.createMock(JPAEdmBuilder.class);
  EasyMock.expect(builder.getSchemas()).andReturn(mockSchemas()).times(10);
  EasyMock.replay(builder);
  return builder;
}

Fixed version (ground truth):
public static JPAEdmBuilder mockjpaEdmBuilder() throws ODataJPAModelException {
  JPAEdmBuilder builder=EasyMock.createMock(JPAEdmBuilder.class);
  return builder;
}
Program: 18090
Project: 18090
Buggy source:
public static void build(JPAEdmAssociationSetView view){
  AssociationSet associationSet=view.getEdmAssociationSet();
  String name=view.getEdmAssociation().getName();
  associationSet.setName(name + ASSOCIATIONSET_SUFFIX);
}

Fixed version (ground truth):
public static void build(JPAEdmAssociationView associationView,JPAEdmPropertyView propertyView,JPAEdmNavigationProperty jpaEdmNavigationProperty){
  NavigationProperty navProp=jpaEdmNavigationProperty.getEdmNavigationProperty();
  String namespace=buildNamespace(associationView.getpUnitName());
  navProp.setRelationship(new FullQualifiedName(namespace,associationView.getEdmAssociation().getName()));
  FullQualifiedName associationEndTypeOne=associationView.getEdmAssociation().getEnd1().getType();
  if (propertyView.getJPAAttribute().getJavaType().getSimpleName().equals(associationEndTypeOne.getName())) {
    navProp.setFromRole(associationView.getEdmAssociation().getEnd2().getRole());
    navProp.setToRole(associationView.getEdmAssociation().getEnd1().getRole());
  }
 else {
    navProp.setToRole(associationView.getEdmAssociation().getEnd2().getRole());
    navProp.setFromRole(associationView.getEdmAssociation().getEnd1().getRole());
  }
  navProp.setName(propertyView.getJPAAttribute().getJavaType().getSimpleName().concat(NAVIGATION_NAME));
}
Program: 18091
Project: 18091
Buggy source:
@Override public Association searchAssociation(JPAEdmAssociationEndView view){
  for (  Association association : consistentAssociatonList)   if (view.compare(association.getEnd1(),association.getEnd2()))   return association;
  return null;
}

Fixed version (ground truth):
@Override public Association searchAssociation(JPAEdmAssociationEndView view){
  for (  Association association : consistentAssociatonList) {
    if (view.compare(association.getEnd1(),association.getEnd2())) {
      currentAssociation=association;
      return association;
    }
  }
  return null;
}
Program: 18092
Project: 18092
Buggy source:
@Override public void addJPAEdmAssociationView(JPAEdmAssociationView associationView){
  consistentAssociatonList.add(associationView.getEdmAssociation());
}

Fixed version (ground truth):
@Override public void addJPAEdmAssociationView(JPAEdmAssociationView associationView){
  currentAssociation=associationView.getEdmAssociation();
  consistentAssociatonList.add(currentAssociation);
}
Program: 18093
Project: 18093
Buggy source:
@Override public void build() throws ODataJPAModelException {
  Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes=metaModel.getEntities();
  if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true)   return;
 else   if (consistentEntityTypes == null) {
    consistentEntityTypes=new ArrayList<EntityType>();
  }
  for (  javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
    currentEdmEntityType=new EntityType();
    currentJPAEntityType=jpaEntityType;
    JPAEdmNameBuilder.build(JPAEdmEntityType.this);
    JPAEdmPropertyView propertyView=new JPAEdmProperty(schemaView);
    propertyView.getBuilder().build();
    currentEdmEntityType.setProperties(propertyView.getPropertyList());
    JPAEdmKeyView keyView=propertyView.getJPAEdmKeyView();
    currentEdmEntityType.setKey(keyView.getEdmKey());
    consistentEntityTypes.add(currentEdmEntityType);
  }
}

Fixed version (ground truth):
@Override public void build() throws ODataJPAModelException {
  Set<javax.persistence.metamodel.EntityType<?>> jpaEntityTypes=metaModel.getEntities();
  if (jpaEntityTypes == null || jpaEntityTypes.isEmpty() == true)   return;
 else   if (consistentEntityTypes == null) {
    consistentEntityTypes=new ArrayList<EntityType>();
  }
  for (  javax.persistence.metamodel.EntityType<?> jpaEntityType : jpaEntityTypes) {
    currentEdmEntityType=new EntityType();
    currentJPAEntityType=jpaEntityType;
    JPAEdmNameBuilder.build(JPAEdmEntityType.this);
    JPAEdmPropertyView propertyView=new JPAEdmProperty(schemaView);
    propertyView.getBuilder().build();
    currentEdmEntityType.setProperties(propertyView.getPropertyList());
    if (propertyView.getJPAEdmNavigationPropertyView() != null) {
      JPAEdmNavigationPropertyView navPropView=propertyView.getJPAEdmNavigationPropertyView();
      if (navPropView.getConsistentEdmNavigationProperties() != null && !navPropView.getConsistentEdmNavigationProperties().isEmpty()) {
        currentEdmEntityType.setNavigationProperties(navPropView.getConsistentEdmNavigationProperties());
      }
    }
    JPAEdmKeyView keyView=propertyView.getJPAEdmKeyView();
    currentEdmEntityType.setKey(keyView.getEdmKey());
    consistentEntityTypes.add(currentEdmEntityType);
  }
}
Program: 18094
Project: 18094
Buggy source:
@Override public void build() throws ODataJPAModelException {
  NavigationProperty navigationProperty=new NavigationProperty();
  JPAEdmEntityTypeView entityTypeView=schemaView.getJPAEdmEntityContainerView().getJPAEdmEntitySetView().getJPAEdmEntityTypeView();
  EntityType<?> jpaEntityType=entityTypeView.getJPAEntityType();
  for (  Attribute<?,?> attribute : jpaEntityType.getAttributes()) {
    PersistentAttributeType attributeType=attribute.getPersistentAttributeType();
switch (attributeType) {
case MANY_TO_MANY:
      break;
case ONE_TO_MANY:
    break;
case MANY_TO_ONE:
  break;
case ONE_TO_ONE:
break;
default :
break;
}
}
}

Fixed version (ground truth):
@Override public void build() throws ODataJPAModelException {
  currentNavigationProperty=new NavigationProperty();
  JPAEdmNameBuilder.build(associationView,propertyView,JPAEdmNavigationProperty.this);
}
Program: 18095
Project: 18095
Buggy source:
public JPAEdmNavigationProperty(JPAEdmSchemaView view){
  super(view);
  this.schemaView=view;
}

Fixed version (ground truth):
public JPAEdmNavigationProperty(JPAEdmSchemaView schemaView){
  super(schemaView);
  consistentNavigationProperties=new ArrayList<NavigationProperty>();
}
Program: 18097
Project: 18097
Buggy source:
@Test public void testGetJPAEdmBuilder(){
  ODataJPAFactoryImpl factory=new ODataJPAFactoryImpl();
  JPAEdmBuilder builder=factory.getJPAAccessFactory().getJPAEdmBuilder(odataJpaContext);
  assertEquals(JPAEdmBuilderV2.class,builder.getClass());
}

Fixed version (ground truth):
@Test public void testGetJPAEdmBuilder(){
  ODataJPAFactoryImpl factory=new ODataJPAFactoryImpl();
}
Program: 18098
Project: 18098
Buggy source:
public static JPAEdmBuilder mockjpaEdmBuilder() throws ODataJPAModelException {
  JPAEdmBuilder builder=EasyMock.createMock(JPAEdmBuilder.class);
  EasyMock.expect(builder.getSchemas()).andReturn(mockSchemas()).times(10);
  EasyMock.replay(builder);
  return builder;
}

Fixed version (ground truth):
public static JPAEdmBuilder mockjpaEdmBuilder() throws ODataJPAModelException {
  JPAEdmBuilder builder=EasyMock.createMock(JPAEdmBuilder.class);
  return builder;
}
Program: 18099
Project: 18099
Buggy source:
/** 
 * This method evaluated the where expression for read of an entity based on the keys specified in the query.
 * @param keyPredicates
 * @return the evaluated where expression
 */
public static String parseKeyPredicates(List<KeyPredicate> keyPredicates,String tableAlias) throws ODataJPARuntimeException {
  String literal=null;
  String propertyName=null;
  EdmSimpleType edmSimpleType=null;
  StringBuilder keyFilters=new StringBuilder();
  int i=0;
  for (  KeyPredicate keyPredicate : keyPredicates) {
    if (i > 0) {
      keyFilters.append(SPACE + JPQLStatement.Operator.AND + SPACE);
    }
    i++;
    literal=keyPredicate.getLiteral();
    try {
      propertyName=keyPredicate.getProperty().getName();
      edmSimpleType=(EdmSimpleType)keyPredicate.getProperty().getType();
    }
 catch (    EdmException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
    }
    literal=evaluateComparingExpression(literal,edmSimpleType);
    keyFilters.append(tableAlias + DOT + propertyName+ SPACE+ JPQLStatement.Operator.EQ+ SPACE+ literal);
  }
  return keyFilters.toString();
}

Fixed version (ground truth):
/** 
 * This method evaluated the where expression for read of an entity based on the keys specified in the query.
 * @param keyPredicates
 * @return the evaluated where expression
 */
public static String parseKeyPredicates(List<KeyPredicate> keyPredicates,String tableAlias) throws ODataJPARuntimeException {
  String literal=null;
  String propertyName=null;
  EdmSimpleType edmSimpleType=null;
  StringBuilder keyFilters=new StringBuilder();
  int i=0;
  for (  KeyPredicate keyPredicate : keyPredicates) {
    if (i > 0) {
      keyFilters.append(JPQLStatement.DELIMITER.SPACE + JPQLStatement.Operator.AND + JPQLStatement.DELIMITER.SPACE);
    }
    i++;
    literal=keyPredicate.getLiteral();
    try {
      propertyName=keyPredicate.getProperty().getMapping().getInternalName();
      edmSimpleType=(EdmSimpleType)keyPredicate.getProperty().getType();
    }
 catch (    EdmException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
    }
    literal=evaluateComparingExpression(literal,edmSimpleType);
    keyFilters.append(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName+ JPQLStatement.DELIMITER.SPACE+ JPQLStatement.Operator.EQ+ JPQLStatement.DELIMITER.SPACE+ literal);
  }
  return keyFilters.toString();
}
Program: 18100
Project: 18100
Buggy source:
public static HashMap<String,String> parseKeyPredicatesToJPAOrderByExpression(List<KeyPredicate> keyPredicates,String tableAlias) throws ODataJPARuntimeException {
  HashMap<String,String> orderByMap=new HashMap<String,String>();
  String propertyName=null;
  for (  KeyPredicate keyPredicate : keyPredicates) {
    try {
      propertyName=keyPredicate.getProperty().getName();
    }
 catch (    EdmException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
    }
    orderByMap.put(tableAlias + DOT + propertyName,EMPTY);
  }
  return orderByMap;
}

Fixed version (ground truth):
public static HashMap<String,String> parseKeyPredicatesToJPAOrderByExpression(List<KeyPredicate> keyPredicates,String tableAlias) throws ODataJPARuntimeException {
  HashMap<String,String> orderByMap=new HashMap<String,String>();
  String propertyName=null;
  for (  KeyPredicate keyPredicate : keyPredicates) {
    try {
      propertyName=keyPredicate.getProperty().getMapping().getInternalName();
    }
 catch (    EdmException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
    }
    orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName,EMPTY);
  }
  return orderByMap;
}
Program: 18102
Project: 18102
Buggy source:
/** 
 * This method parses the order by condition in the query.
 * @param orderByExpression
 * @return
 * @throws ODataJPARuntimeException
 */
public static HashMap<String,String> parseToJPAOrderByExpression(OrderByExpression orderByExpression,String tableAlias) throws ODataJPARuntimeException {
  HashMap<String,String> orderByMap=new HashMap<String,String>();
  if (orderByExpression != null && orderByExpression.getOrders() != null) {
    List<OrderExpression> orderBys=orderByExpression.getOrders();
    String orderByField=null;
    String orderByDirection=null;
    for (    OrderExpression orderBy : orderBys) {
      try {
        orderByField=orderBy.getExpression().getEdmType().getName();
        orderByDirection=(orderBy.getSortOrder() == SortOrder.asc) ? EMPTY : "String_Node_Str";
        orderByMap.put(tableAlias + DOT + orderByField,orderByDirection);
      }
 catch (      EdmException e) {
        throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
      }
    }
  }
  return orderByMap;
}

Fixed version (ground truth):
/** 
 * This method parses the order by condition in the query.
 * @param orderByExpression
 * @return
 * @throws ODataJPARuntimeException
 */
public static HashMap<String,String> parseToJPAOrderByExpression(OrderByExpression orderByExpression,String tableAlias) throws ODataJPARuntimeException {
  HashMap<String,String> orderByMap=new HashMap<String,String>();
  if (orderByExpression != null && orderByExpression.getOrders() != null) {
    List<OrderExpression> orderBys=orderByExpression.getOrders();
    String orderByField=null;
    String orderByDirection=null;
    for (    OrderExpression orderBy : orderBys) {
      try {
        orderByField=((EdmProperty)((PropertyExpression)orderBy.getExpression()).getEdmProperty()).getMapping().getInternalName();
        orderByDirection=(orderBy.getSortOrder() == SortOrder.asc) ? EMPTY : "String_Node_Str";
        orderByMap.put(tableAlias + JPQLStatement.DELIMITER.PERIOD + orderByField,orderByDirection);
      }
 catch (      EdmException e) {
        throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.RUNTIME_EXCEPTION.addContent(e.getMessage()),e);
      }
    }
  }
  return orderByMap;
}
Program: 18103
Project: 18103
Buggy source:
protected ArrayList<String> generateSelectFields() throws EdmException {
  List<SelectItem> selectItemList=entitySetView.getSelect();
  if (selectItemList != null) {
    ArrayList<String> selectedFields=new ArrayList<String>(selectItemList.size());
    for (    SelectItem item : selectItemList) {
      selectedFields.add(item.getProperty().getName());
    }
    return selectedFields;
  }
  return null;
}

Fixed version (ground truth):
protected ArrayList<String> generateSelectFields() throws EdmException {
  List<SelectItem> selectItemList=entitySetView.getSelect();
  if (selectItemList != null) {
    ArrayList<String> selectedFields=new ArrayList<String>(selectItemList.size());
    for (    SelectItem item : selectItemList) {
      selectedFields.add(((EdmProperty)item.getProperty()).getMapping().getInternalName());
    }
    return selectedFields;
  }
  return null;
}
Program: 18104
Project: 18104
Buggy source:
protected ArrayList<String> generateSelectFields() throws EdmException {
  List<SelectItem> selectItemList=entityView.getSelect();
  if (selectItemList != null) {
    ArrayList<String> selectedFields=new ArrayList<String>(selectItemList.size());
    for (    SelectItem item : selectItemList) {
      selectedFields.add(item.getProperty().getName());
    }
    return selectedFields;
  }
  return null;
}

Fixed version (ground truth):
protected ArrayList<String> generateSelectFields() throws EdmException {
  List<SelectItem> selectItemList=entityView.getSelect();
  if (selectItemList != null) {
    ArrayList<String> selectedFields=new ArrayList<String>(selectItemList.size());
    for (    SelectItem item : selectItemList) {
      selectedFields.add(((EdmProperty)item.getProperty()).getMapping().getInternalName());
    }
    return selectedFields;
  }
  return null;
}
Program: 18106
Project: 18106
Buggy source:
private EdmSimpleType getEdmSimpleTypeMockedObj(String value) throws EdmException {
  EdmSimpleType edmSimpleType=EasyMock.createMock(EdmSimpleType.class);
  EasyMock.expect(edmSimpleType.getName()).andReturn(value);
  EasyMock.expect(edmSimpleType.getKind()).andReturn(EdmTypeKind.SIMPLE).times(10);
  EasyMock.expect(edmSimpleType.valueOfString(value,EdmLiteralKind.URI,getEdmFacetsMockedObj())).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueOfString(value,EdmLiteralKind.URI,null)).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueToString(value,EdmLiteralKind.DEFAULT,getEdmFacetsMockedObj())).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueToString(value,EdmLiteralKind.DEFAULT,null)).andReturn(value).times(10);
  EasyMock.replay(edmSimpleType);
  return edmSimpleType;
}

Fixed version (ground truth):
private EdmSimpleType getEdmSimpleTypeMockedObj(String value) throws EdmException {
  EdmSimpleType edmSimpleType=EasyMock.createMock(EdmSimpleType.class);
  EasyMock.expect(edmSimpleType.getName()).andReturn(value);
  EasyMock.expect(edmSimpleType.getKind()).andReturn(EdmTypeKind.SIMPLE).times(10);
  EasyMock.expect(edmSimpleType.valueOfString(value,EdmLiteralKind.URI,getEdmFacetsMockedObj(),null)).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueOfString(value,EdmLiteralKind.URI,null,null)).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueToString(value,EdmLiteralKind.DEFAULT,getEdmFacetsMockedObj())).andReturn(value).times(10);
  EasyMock.expect(edmSimpleType.valueToString(value,EdmLiteralKind.DEFAULT,null)).andReturn(value).times(10);
  EasyMock.replay(edmSimpleType);
  return edmSimpleType;
}
Program: 18108
Project: 18108
Buggy source:
public void generate(){
  this.entityManager.getTransaction().begin();
  int count=0;
  for (int i=0; i < DataGenerator.MAX_SALESORDER; i++) {
    Address ba=new Address((short)i,"String_Node_Str" + i,"String_Node_Str" + i,"String_Node_Str" + i);
    SalesOrderHeader salesOrder=new SalesOrderHeader(i,"String_Node_Str" + i,ba,"String_Node_Str" + i,(double)i,((i % 2) == 0) ? true : false);
    for (int j=0; j < DataGenerator.MAX_SALESORDERITEM_PER_SALESORDER; j++) {
      SalesOrderItem salesOrderItem=new SalesOrderItem("String_Node_Str" + j,j,(double)((j * 200) / 4));
      salesOrderItem.setSalesOrderItemKey(new SalesOrderItemKey(j * 100));
      salesOrder.getSalesOrderItem().add(salesOrderItem);
      this.entityManager.persist(salesOrderItem);
    }
    Note note=new Note("String_Node_Str" + i,new Date(),"String_Node_Str" + i);
    salesOrder.setNote(note);
    this.entityManager.persist(note);
    this.entityManager.persist(salesOrder);
    count++;
    if ((i == 7) && (count == 8)) {
      i--;
    }
  }
  this.entityManager.getTransaction().commit();
}

Fixed version (ground truth):
public void generate(){
  this.entityManager.getTransaction().begin();
  generatedDataFromFile();
  this.entityManager.getTransaction().commit();
}
Program: 18109
Project: 18109
Buggy source:
public static ODataResponse build(Object jpaEntity,GetEntityUriInfo resultsView,String contentType,ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
  EdmEntityType edmEntityType=null;
  ODataResponse odataResponse=null;
  try {
    edmEntityType=resultsView.getTargetEntitySet().getEntityType();
    Map<String,Object> edmPropertyValueMap=null;
    JPAResultParser jpaResultParser=JPAResultParser.create();
    edmPropertyValueMap=jpaResultParser.parse2EdmPropertyValueMap(jpaEntity,edmEntityType);
    EntityProviderProperties feedProperties=null;
    try {
      feedProperties=EntityProviderProperties.baseUri(oDataJPAContext.getODataContext().getUriInfo().getServiceRoot()).build();
    }
 catch (    ODataException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
    }
    odataResponse=ODataResponse.fromResponse(EntityProvider.create(contentType).writeEntry(resultsView.getTargetEntitySet(),edmPropertyValueMap,feedProperties)).status(HttpStatusCodes.OK).build();
  }
 catch (  EntityProviderException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
  }
catch (  EdmException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
  }
  return odataResponse;
}

Fixed version (ground truth):
public static ODataResponse build(Object jpaEntity,GetEntityUriInfo resultsView,String contentType,ODataJPAContext oDataJPAContext) throws ODataJPARuntimeException {
  EdmEntityType edmEntityType=null;
  ODataResponse odataResponse=null;
  try {
    edmEntityType=resultsView.getTargetEntitySet().getEntityType();
    Map<String,Object> edmPropertyValueMap=null;
    JPAResultParser jpaResultParser=JPAResultParser.create();
    edmPropertyValueMap=jpaResultParser.parse2EdmPropertyValueMap(jpaEntity,edmEntityType);
    EntityProviderProperties feedProperties=null;
    try {
      feedProperties=EntityProviderProperties.baseUri(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot()).build();
    }
 catch (    ODataException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
    }
    odataResponse=ODataResponse.fromResponse(EntityProvider.create(contentType).writeEntry(resultsView.getTargetEntitySet(),edmPropertyValueMap,feedProperties)).status(HttpStatusCodes.OK).build();
  }
 catch (  EntityProviderException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
  }
catch (  EdmException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()),e);
  }
  return odataResponse;
}
Program: 18113
Project: 18113
Buggy source:
/** 
 * Add given content to message reference.
 */
public MessageReference addContent(Object... content){
  return new SimpleMessageReference(this.key,content);
}

Fixed version (ground truth):
/** 
 * Add given content to message reference.
 */
public MessageReference addContent(Object... content){
  if (this.content == null) {
    return new SimpleMessageReference(this.key,content);
  }
 else {
    List<Object> mergedContent=new ArrayList<Object>(this.content.size() + content.length);
    mergedContent.addAll(this.content);
    mergedContent.addAll(Arrays.asList(content));
    return new SimpleMessageReference(this.key,mergedContent);
  }
}
Program: 18114
Project: 18114
Buggy source:
@Override public Response toResponse(Exception exception){
  final Response response;
  Exception toHandleException=extractException(exception);
  exception.printStackTrace();
  if (toHandleException instanceof ODataApplicationException) {
    response=buildResponseForApplicationException((ODataApplicationException)toHandleException);
  }
 else   if (toHandleException instanceof ODataHttpException) {
    response=buildResponseForHttpException((ODataHttpException)toHandleException);
  }
 else {
    response=buildResponseForException(exception);
  }
  if (isInternalServerError(response)) {
    ODataExceptionMapperImpl.LOG.error(exception.getMessage(),exception);
  }
  return response;
}

Fixed version (ground truth):
@Override public Response toResponse(Exception exception){
  final Response response;
  Exception toHandleException=extractException(exception);
  if (toHandleException instanceof ODataApplicationException) {
    response=buildResponseForApplicationException((ODataApplicationException)toHandleException);
  }
 else   if (toHandleException instanceof ODataHttpException) {
    response=buildResponseForHttpException((ODataHttpException)toHandleException);
  }
 else {
    response=buildResponseForException(exception);
  }
  if (isInternalServerError(response)) {
    ODataExceptionMapperImpl.LOG.error(exception.getMessage(),exception);
  }
  return response;
}
Program: 18115
Project: 18115
Buggy source:
@Test public void test500RuntimeError() throws ClientProtocolException, IOException, ODataException {
  HttpGet get=new HttpGet(URI.create(this.getEndpoint().toString()));
  HttpResponse response=this.getHttpClient().execute(get);
  assertEquals(500,response.getStatusLine().getStatusCode());
  this.log.debug(StringHelper.inputStreamToString(response.getEntity().getContent()));
}

Fixed version (ground truth):
@Test public void test500RuntimeError() throws ClientProtocolException, IOException, ODataException {
  disableLogging(ODataExceptionMapperImpl.class);
  HttpGet get=new HttpGet(URI.create(this.getEndpoint().toString()));
  HttpResponse response=this.getHttpClient().execute(get);
  assertEquals(500,response.getStatusLine().getStatusCode());
  this.log.debug(StringHelper.inputStreamToString(response.getEntity().getContent()));
}
Program: 18116
Project: 18116
Buggy source:
@After public void after(){
  try {
    this.server.stopServer();
  }
  finally {
    FitStaticServiceFactory.setService(null);
  }
}

Fixed version (ground truth):
@After public void after(){
  reEnableLogging();
  try {
    this.server.stopServer();
  }
  finally {
    FitStaticServiceFactory.setService(null);
  }
}
Program: 18117
Project: 18117
Buggy source:
private Response buildResponseForApplicationException(ODataApplicationException exception){
  ResponseBuilder responseBuilder=Response.noContent();
  Status status=extractStatus(exception);
  return responseBuilder.entity(exception.getMessage()).status(status).build();
}

Fixed version (ground truth):
private Response buildResponseForApplicationException(ODataApplicationException exception){
  ResponseBuilder responseBuilder=Response.noContent();
  int statusCode=extractStatus(exception);
  return responseBuilder.entity(exception.getMessage()).status(statusCode).build();
}
Program: 18118
Project: 18118
Buggy source:
private Status extractStatus(ODataException exception){
  Status extractedStatus=Status.INTERNAL_SERVER_ERROR;
  HttpStatusCodes httpStatus=null;
  if (exception instanceof ODataHttpException) {
    httpStatus=((ODataHttpException)exception).getHttpStatus();
  }
 else   if (exception instanceof ODataApplicationException) {
    httpStatus=((ODataApplicationException)exception).getHttpStatus();
  }
  if (httpStatus != null) {
    try {
      extractedStatus=Status.valueOf(httpStatus.name());
    }
 catch (    IllegalArgumentException e) {
      LOG.error("String_Node_Str",e);
    }
  }
  return extractedStatus;
}

Fixed version (ground truth):
private int extractStatus(ODataException exception){
  int extractedStatusCode=HttpStatusCodes.INTERNAL_SERVER_ERROR.getStatusCode();
  if (exception instanceof ODataHttpException) {
    extractedStatusCode=((ODataHttpException)exception).getHttpStatus().getStatusCode();
  }
 else   if (exception instanceof ODataApplicationException) {
    extractedStatusCode=((ODataApplicationException)exception).getHttpStatus().getStatusCode();
  }
  return extractedStatusCode;
}
Program: 18119
Project: 18119
Buggy source:
@Test public void testGenericHttpExceptions() throws ClientProtocolException, IOException, ODataException {
  List<ODataHttpException> toTestExceptions=new ArrayList<ODataHttpException>();
  toTestExceptions.add(new ODataNotFoundException(ODataNotFoundException.ENTITY));
  toTestExceptions.add(new ODataBadRequestException(ODataBadRequestException.COMMON));
  toTestExceptions.add(new ODataForbiddenException(ODataForbiddenException.COMMON));
  int firstKey=1;
  for (  ODataHttpException oDataException : toTestExceptions) {
    String key=String.valueOf(firstKey++);
    Matcher<GetEntityView> match=new EntityKeyMatcher(key);
    when(processor.readEntity(Matchers.argThat(match))).thenThrow(oDataException);
    String uri=getEndpoint().toString() + "String_Node_Str" + key+ "String_Node_Str";
    HttpGet get=new HttpGet(URI.create(uri));
    HttpResponse response=getHttpClient().execute(get);
    assertEquals("String_Node_Str" + oDataException.getClass().getSimpleName() + "String_Node_Str",oDataException.getHttpStatus().getStatusCode(),response.getStatusLine().getStatusCode());
    get.releaseConnection();
  }
}

Fixed version (ground truth):
@Test public void testGenericHttpExceptions() throws Exception {
  List<ODataHttpException> toTestExceptions=getHttpExceptionsForTest();
  int firstKey=1;
  for (  ODataHttpException oDataException : toTestExceptions) {
    String key=String.valueOf(firstKey++);
    Matcher<GetEntityView> match=new EntityKeyMatcher(key);
    when(processor.readEntity(Matchers.argThat(match))).thenThrow(oDataException);
    String uri=getEndpoint().toString() + "String_Node_Str" + key+ "String_Node_Str";
    HttpGet get=new HttpGet(URI.create(uri));
    HttpResponse response=getHttpClient().execute(get);
    assertEquals("String_Node_Str" + oDataException.getClass().getSimpleName() + "String_Node_Str",oDataException.getHttpStatus().getStatusCode(),response.getStatusLine().getStatusCode());
    get.releaseConnection();
  }
}
Program: 18120
Project: 18120
Buggy source:
public EdmElementImplProv(EdmImplProv edm,String name,FullQualifiedName typeName,EdmFacets edmFacets,EdmMapping edmMapping) throws EdmException {
  super(edm,name,typeName,edmFacets == null || edmFacets.isNullable() ? EdmMultiplicity.ZERO_TO_ONE : EdmMultiplicity.ONE);
}

Fixed version (ground truth):
public EdmElementImplProv(EdmImplProv edm,String name,FullQualifiedName typeName,EdmFacets edmFacets,EdmMapping edmMapping) throws EdmException {
  super(edm,name,typeName,edmFacets == null || edmFacets.isNullable() ? EdmMultiplicity.ZERO_TO_ONE : EdmMultiplicity.ONE);
  this.edmFacets=edmFacets;
  this.edmMapping=edmMapping;
}
Program: 18121
Project: 18121
Buggy source:
@Override protected EdmEntityContainer createEntityContainer(String name) throws ODataException {
  return new EdmEntityContainerImplProv(this,edmProvider.getEntityContainer(name));
}

Fixed version (ground truth):
@Override protected EdmEntityContainer createEntityContainer(String name) throws ODataException {
  EntityContainerInfo enitityContainerInfo=edmProvider.getEntityContainer(name);
  if (enitityContainerInfo == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return new EdmEntityContainerImplProv(this,enitityContainerInfo);
}
Program: 18122
Project: 18122
Buggy source:
@Override protected EdmComplexType createComplexType(FullQualifiedName fqName) throws ODataException {
  return new EdmComplexTypeImplProv(this,edmProvider.getComplexType(fqName),fqName.getNamespace());
}

Fixed version (ground truth):
@Override protected EdmComplexType createComplexType(FullQualifiedName fqName) throws ODataException {
  ComplexType complexType=edmProvider.getComplexType(fqName);
  if (complexType == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return new EdmComplexTypeImplProv(this,complexType,fqName.getNamespace());
}
Program: 18123
Project: 18123
Buggy source:
@Override protected EdmAssociation createAssociation(FullQualifiedName fqName) throws ODataException {
  return new EdmAssociationImplProv(this,edmProvider.getAssociation(fqName),fqName.getNamespace());
}

Fixed version (ground truth):
@Override protected EdmAssociation createAssociation(FullQualifiedName fqName) throws ODataException {
  Association association=edmProvider.getAssociation(fqName);
  if (association == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return new EdmAssociationImplProv(this,association,fqName.getNamespace());
}
Program: 18124
Project: 18124
Buggy source:
@Override protected EdmEntityType createEntityType(FullQualifiedName fqName) throws ODataException {
  return new EdmEntityTypeImplProv(this,edmProvider.getEntityType(fqName),fqName.getNamespace());
}

Fixed version (ground truth):
@Override protected EdmEntityType createEntityType(FullQualifiedName fqName) throws ODataException {
  EntityType entityType=edmProvider.getEntityType(fqName);
  if (entityType == null) {
    throw new EdmException(EdmException.COMMON);
  }
  return new EdmEntityTypeImplProv(this,entityType,fqName.getNamespace());
}
Program: 18125
Project: 18125
Buggy source:
private void splitPath(InitParameter param) throws ODataException {
  List<PathSegment> precedingPathSegements;
  List<PathSegment> odataPathSegements;
  if (param.getPathSplit() == 0) {
    precedingPathSegements=Collections.emptyList();
    odataPathSegements=param.getPathSegments();
  }
 else {
    if (param.getPathSegments().size() < param.getPathSplit()) {
      throw new ODataBadRequestException(ODataBadRequestException.URLTOSHORT);
    }
    precedingPathSegements=param.getPathSegments().subList(0,param.getPathSplit());
    int pathSegmentCount=param.getPathSegments().size();
    odataPathSegements=param.getPathSegments().subList(param.getPathSplit(),pathSegmentCount);
  }
  for (  PathSegment ps : odataPathSegements) {
    if (!ps.getMatrixParameters().isEmpty()) {
      throw new ODataNotFoundException(ODataNotFoundException.MATRIX);
    }
  }
  this.context.setODataPathSegment(this.convertPathSegmentList(odataPathSegements));
  this.context.setPrecedingPathSegment(this.convertPathSegmentList(precedingPathSegements));
}

Fixed version (ground truth):
private void splitPath(InitParameter param) throws ODataException {
  List<PathSegment> precedingPathSegements;
  List<PathSegment> odataPathSegements;
  if (param.getPathSplit() == 0) {
    precedingPathSegements=Collections.emptyList();
    odataPathSegements=param.getPathSegments();
  }
 else {
    if (param.getPathSegments().size() < param.getPathSplit()) {
      throw new ODataBadRequestException(ODataBadRequestException.URLTOSHORT);
    }
    precedingPathSegements=param.getPathSegments().subList(0,param.getPathSplit());
    int pathSegmentCount=param.getPathSegments().size();
    odataPathSegements=param.getPathSegments().subList(param.getPathSplit(),pathSegmentCount);
  }
  for (  PathSegment ps : odataPathSegements) {
    if (ps.getMatrixParameters() != null && !ps.getMatrixParameters().isEmpty()) {
      throw new ODataNotFoundException(ODataNotFoundException.MATRIX);
    }
  }
  this.context.setODataPathSegment(this.convertPathSegmentList(odataPathSegements));
  this.context.setPrecedingPathSegment(this.convertPathSegmentList(precedingPathSegements));
}
Program: 18126
Project: 18126
Buggy source:
@Override public EdmEntitySet getRelatedEntitySet(EdmNavigationProperty navigationProperty) throws EdmException {
  return null;
}

Fixed version (ground truth):
@Override public EdmEntitySet getRelatedEntitySet(EdmNavigationProperty navigationProperty) throws EdmException {
  EdmAssociationSet associationSet=edmEntityContainer.getAssociationSet(edmEntityContainer.getEntitySet(entitySet.getName()),navigationProperty);
  if (associationSet == null)   throw new EdmException();
  EdmAssociationSetEnd toEnd=associationSet.getEnd(navigationProperty.getToRole());
  if (toEnd == null)   throw new EdmException();
  EdmEntitySet targetEntitySet=toEnd.getEntitySet();
  if (targetEntitySet == null)   throw new EdmException();
  return targetEntitySet;
}
Program: 18127
Project: 18127
Buggy source:
@Override public Collection<String> getKeyPropertyNames() throws EdmException {
  return entityType.getKey().getKeys().keySet();
}

Fixed version (ground truth):
@Override public Collection<String> getKeyPropertyNames() throws EdmException {
  if (entityType.getKey() == null)   return Collections.<String>emptyList();
 else   return entityType.getKey().getKeys().keySet();
}
Program: 18128
Project: 18128
Buggy source:
@Override public List<EdmProperty> getKeyProperties() throws EdmException {
  if (edmKeyProperties == null) {
    String keyPropertyName;
    EdmProperty edmProperty;
    Collection<String> keyPropertyNames=getKeyPropertyNames();
    for (Iterator<String> iterator=keyPropertyNames.iterator(); iterator.hasNext(); ) {
      keyPropertyName=iterator.next();
      try {
        edmProperty=(EdmProperty)getProperty(keyPropertyName);
      }
 catch (      ClassCastException e) {
        throw new EdmException(e);
      }
      if (edmProperty != null) {
        edmKeyProperties.add(edmProperty);
      }
 else {
        throw new EdmException();
      }
    }
  }
  return edmKeyProperties;
}

Fixed version (ground truth):
@Override public List<EdmProperty> getKeyProperties() throws EdmException {
  if (edmKeyProperties == null) {
    EdmProperty edmProperty;
    edmKeyProperties=new ArrayList<EdmProperty>();
    for (    String keyPropertyName : getKeyPropertyNames()) {
      try {
        edmProperty=(EdmProperty)getProperty(keyPropertyName);
      }
 catch (      ClassCastException e) {
        throw new EdmException(e);
      }
      if (edmProperty != null) {
        edmKeyProperties.add(edmProperty);
      }
 else {
        throw new EdmException();
      }
    }
    if (edmBaseType != null)     edmKeyProperties.addAll(((EdmEntityType)edmBaseType).getKeyProperties());
  }
  return edmKeyProperties;
}
Program: 18130
Project: 18130
Buggy source:
private Integer applySystemQueryOptions(final EdmEntitySet targetEntitySet,List<?> data,final InlineCount inlineCount,final String filter,final String orderBy,final String skipToken,final int skip,final Integer top){
  if (filter != null)   for (  Object element : data)   if (!appliesFilter(element,filter))   data.remove(element);
  final Integer count=inlineCount == InlineCount.ALLPAGES ? data.size() : null;
  if (orderBy != null)   ;
 else   if (skipToken != null || skip != 0 || top != null)   ;
  if (skipToken != null)   ;
  for (int i=0; i < skip; i++)   data.remove(0);
  if (top != null)   while (data.size() > top)   data.remove(top.intValue());
  return count;
}

Fixed version (ground truth):
private Integer applySystemQueryOptions(final EdmEntitySet targetEntitySet,List<?> data,final InlineCount inlineCount,final String filter,final String orderBy,final String skipToken,final int skip,final Integer top) throws ODataException {
  if (filter != null)   for (  Object element : data)   if (!appliesFilter(element,filter))   data.remove(element);
  final Integer count=inlineCount == InlineCount.ALLPAGES ? data.size() : null;
  if (orderBy != null)   ;
 else   if (skipToken != null || skip != 0 || top != null)   if (data instanceof Comparable<?>)   Collections.sort((List<? extends Comparable<Object>>)data);
 else   throw new ODataException();
  if (skipToken != null)   ;
  for (int i=0; i < skip; i++)   data.remove(0);
  if (top != null)   while (data.size() > top)   data.remove(top.intValue());
  return count;
}
Program: 18131
Project: 18131
Buggy source:
@Override public Object readRelatedData(final EdmEntitySet sourceEntitySet,final Object sourceData,final EdmEntitySet targetEntitySet,final Map<String,Object> targetKeys) throws ODataException {
  if ("String_Node_Str".equals(targetEntitySet.getName())) {
    ArrayList<Object> data=new ArrayList<Object>();
    if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getTeam().getId().equals(((Team)sourceData).getId()))       data.add(employee);
    }
 else     if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getRoom().getId().equals(((Room)sourceData).getId()))       data.add(employee);
    }
 else     if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getManager().getId().equals(((Manager)sourceData).getId()))       data.add(employee);
    }
    if (data.isEmpty())     throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
 else     return data;
  }
 else {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }
}

Fixed version (ground truth):
@Override public Object readRelatedData(final EdmEntitySet sourceEntitySet,final Object sourceData,final EdmEntitySet targetEntitySet,final Map<String,Object> targetKeys) throws ODataException {
  if ("String_Node_Str".equals(targetEntitySet.getName())) {
    ArrayList<Object> data=new ArrayList<Object>();
    if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getTeam().getId().equals(((Team)sourceData).getId()))       data.add(employee);
    }
 else     if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getRoom().getId().equals(((Room)sourceData).getId()))       data.add(employee);
    }
 else     if ("String_Node_Str".equals(sourceEntitySet.getName())) {
      for (      final Employee employee : dataContainer.getEmployeeSet())       if (employee.getManager().getId().equals(((Manager)sourceData).getId()))       data.add(employee);
    }
    if (data.isEmpty())     throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
 else     return data;
  }
 else   if ("String_Node_Str".equals(targetEntitySet.getName())) {
    if (((Employee)sourceData).getTeam() == null)     throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
 else     return ((Employee)sourceData).getTeam();
  }
 else   if ("String_Node_Str".equals(targetEntitySet.getName())) {
    return null;
  }
 else {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }
}
Program: 18132
Project: 18132
Buggy source:
private void handleNormalInitialSegment() throws UriParserException, EdmException {
  final Matcher matcher=INITIAL_SEGMENT_PATTERN.matcher(currentPathSegment);
  if (!matcher.matches())   throw new UriParserException("String_Node_Str" + currentPathSegment);
  final String entityContainerName=matcher.group(1);
  final String segmentName=matcher.group(2);
  final String keyPredicate=matcher.group(3);
  final String emptyParentheses=matcher.group(4);
  UriParserImpl.LOG.debug("String_Node_Str" + currentPathSegment + "String_Node_Str"+ entityContainerName+ "String_Node_Str"+ segmentName+ "String_Node_Str"+ keyPredicate+ "String_Node_Str"+ emptyParentheses);
  uriResult.setEntityContainer(entityContainerName == null ? edm.getDefaultEntityContainer() : edm.getEntityContainer(entityContainerName));
  EdmEntitySet entitySet=null;
  EdmFunctionImport functionImport=null;
  try {
    entitySet=uriResult.getEntityContainer().getEntitySet(segmentName);
  }
 catch (  EdmException e) {
    functionImport=uriResult.getEntityContainer().getFunctionImport(segmentName);
  }
  if (entitySet != null) {
    uriResult.setStartEntitySet(entitySet);
    handleEntitySet(entitySet,keyPredicate);
  }
 else {
    uriResult.setFunctionImport(functionImport);
    handleFunctionImport(functionImport,emptyParentheses,keyPredicate);
  }
}

Fixed version (ground truth):
private void handleNormalInitialSegment() throws UriParserException, EdmException {
  final Matcher matcher=INITIAL_SEGMENT_PATTERN.matcher(currentPathSegment);
  if (!matcher.matches())   throw new UriParserException("String_Node_Str" + currentPathSegment);
  final String entityContainerName=matcher.group(1);
  final String segmentName=matcher.group(2);
  final String keyPredicate=matcher.group(3);
  final String emptyParentheses=matcher.group(4);
  UriParserImpl.LOG.debug("String_Node_Str" + currentPathSegment + "String_Node_Str"+ entityContainerName+ "String_Node_Str"+ segmentName+ "String_Node_Str"+ keyPredicate+ "String_Node_Str"+ emptyParentheses);
  uriResult.setEntityContainer(entityContainerName == null ? edm.getDefaultEntityContainer() : edm.getEntityContainer(entityContainerName));
  EdmEntitySet entitySet=null;
  EdmFunctionImport functionImport=null;
  try {
    entitySet=uriResult.getEntityContainer().getEntitySet(segmentName);
  }
 catch (  EdmException e) {
    functionImport=uriResult.getEntityContainer().getFunctionImport(segmentName);
  }
  if (entitySet != null) {
    uriResult.setStartEntitySet(entitySet);
    handleEntitySet(entitySet,keyPredicate);
  }
 else   if (functionImport != null) {
    uriResult.setFunctionImport(functionImport);
    handleFunctionImport(functionImport,emptyParentheses,keyPredicate);
  }
 else {
    throw new UriParserException("String_Node_Str" + segmentName);
  }
}