nus-yam/ex-repair huggingface dataset:
Program: 33159
Project: 33159
Buggy source:
private static UriParameter simpleKey(UriTokenizer tokenizer,final EdmKeyPropertyRef edmKeyPropertyRef,final Edm edm,final EdmType referringType,final Map<String,AliasQueryOption> aliases) throws UriParserException, UriValidationException {
  final EdmProperty edmProperty=edmKeyPropertyRef == null ? null : edmKeyPropertyRef.getProperty();
  if (nextPrimitiveTypeValue(tokenizer,edmProperty == null ? null : (EdmPrimitiveType)edmProperty.getType(),edmProperty == null ? false : edmProperty.isNullable())) {
    final String literalValue=tokenizer.getText();
    ParserHelper.requireNext(tokenizer,TokenKind.CLOSE);
    return createUriParameter(edmProperty,edmKeyPropertyRef.getName(),literalValue,edm,referringType,aliases);
  }
 else {
    throw new UriParserSemanticException("String_Node_Str",UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE,edmKeyPropertyRef.getName());
  }
}

Fixed version (ground truth):
private static UriParameter simpleKey(UriTokenizer tokenizer,final EdmKeyPropertyRef edmKeyPropertyRef,final Edm edm,final EdmType referringType,final Map<String,AliasQueryOption> aliases) throws UriParserException, UriValidationException {
  final EdmProperty edmProperty=edmKeyPropertyRef == null ? null : edmKeyPropertyRef.getProperty();
  final EdmPrimitiveType primitiveType=edmProperty == null ? null : (EdmPrimitiveType)edmProperty.getType();
  final boolean nullable=edmProperty != null && edmProperty.isNullable();
  if (nextPrimitiveTypeValue(tokenizer,primitiveType,nullable)) {
    final String literalValue=tokenizer.getText();
    ParserHelper.requireNext(tokenizer,TokenKind.CLOSE);
    return createUriParameter(edmProperty,edmKeyPropertyRef.getName(),literalValue,edm,referringType,aliases);
  }
 else {
    String keyPropertyRefName=edmKeyPropertyRef == null ? "String_Node_Str" : edmKeyPropertyRef.getName();
    throw new UriParserSemanticException("String_Node_Str",UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE,keyPropertyRefName);
  }
}
Program: 33161
Project: 33161
Buggy source:
@Override public String toString(){
  return type == null ? null : type.getFullQualifiedName().getFullQualifiedNameAsString() + getValues();
}

Fixed version (ground truth):
@Override public String toString(){
  return type == null ? "String_Node_Str" : type.getFullQualifiedName().getFullQualifiedNameAsString() + getValues();
}
Program: 33162
Project: 33162
Buggy source:
@Override public String toString(){
  return type == null ? null : type.getFullQualifiedName().getFullQualifiedNameAsString();
}

Fixed version (ground truth):
@Override public String toString(){
  return type == null ? "String_Node_Str" : type.getFullQualifiedName().getFullQualifiedNameAsString();
}
Program: 33163
Project: 33163
Buggy source:
@Override public SerializerResult complexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final ComplexSerializerOptions options) throws SerializerException {
  OutputStream outputStream=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    CircleStreamBuffer buffer=new CircleStreamBuffer();
    outputStream=buffer.getOutputStream();
    JsonGenerator json=new JsonFactory().createGenerator(outputStream);
    json.writeStartObject();
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    json.writeFieldName(Constants.VALUE);
    writeComplexCollection(type,property,null,json);
    json.writeEndObject();
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException(IO_EXCEPTION_TEXT,e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}

Fixed version (ground truth):
@Override public SerializerResult complexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final ComplexSerializerOptions options) throws SerializerException {
  OutputStream outputStream=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    CircleStreamBuffer buffer=new CircleStreamBuffer();
    outputStream=buffer.getOutputStream();
    JsonGenerator json=new JsonFactory().createGenerator(outputStream);
    json.writeStartObject();
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    json.writeFieldName(Constants.VALUE);
    writeComplexCollection(metadata,type,property,null,json);
    json.writeEndObject();
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException(IO_EXCEPTION_TEXT,e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33164
Project: 33164
Buggy source:
protected void writeProperty(final EdmProperty edmProperty,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeFieldName(edmProperty.getName());
  if (property == null || property.isNull()) {
    if (edmProperty.isNullable() == Boolean.FALSE) {
      throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.MISSING_PROPERTY,edmProperty.getName());
    }
 else {
      if (edmProperty.isCollection()) {
        json.writeStartArray();
        json.writeEndArray();
      }
 else {
        json.writeNull();
      }
    }
  }
 else {
    writePropertyValue(edmProperty,property,selectedPaths,json);
  }
}

Fixed version (ground truth):
protected void writeProperty(final ServiceMetadata metadata,final EdmProperty edmProperty,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeFieldName(edmProperty.getName());
  if (property == null || property.isNull()) {
    if (edmProperty.isNullable() == Boolean.FALSE) {
      throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.MISSING_PROPERTY,edmProperty.getName());
    }
 else {
      if (edmProperty.isCollection()) {
        json.writeStartArray();
        json.writeEndArray();
      }
 else {
        json.writeNull();
      }
    }
  }
 else {
    writePropertyValue(metadata,edmProperty,property,selectedPaths,json);
  }
}
Program: 33167
Project: 33167
Buggy source:
protected void writeComplexValue(final EdmComplexType type,final List<Property> properties,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeStartObject();
  for (  final String propertyName : type.getPropertyNames()) {
    final Property property=findProperty(propertyName,properties);
    if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths,propertyName)) {
      writeProperty((EdmProperty)type.getProperty(propertyName),property,selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths,propertyName),json);
    }
  }
  json.writeEndObject();
}

Fixed version (ground truth):
protected void writeComplexValue(final ServiceMetadata metadata,final Property complexProperty,final EdmComplexType type,final List<Property> properties,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeStartObject();
  final EdmComplexType resolvedType=resolveComplexType(metadata,type,complexProperty.getType());
  if (!isODataMetadataNone && !resolvedType.equals(type)) {
    json.writeStringField(Constants.JSON_TYPE,"String_Node_Str" + complexProperty.getType());
  }
  for (  final String propertyName : resolvedType.getPropertyNames()) {
    final Property property=findProperty(propertyName,properties);
    if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths,propertyName)) {
      writeProperty(metadata,(EdmProperty)resolvedType.getProperty(propertyName),property,selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths,propertyName),json);
    }
  }
  json.writeEndObject();
}
Program: 33168
Project: 33168
Buggy source:
private void writeComplexCollection(final EdmComplexType type,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeStartArray();
  for (  Object value : property.asCollection()) {
switch (property.getValueType()) {
case COLLECTION_COMPLEX:
      writeComplexValue(type,((ComplexValue)value).getValue(),selectedPaths,json);
    break;
default :
  throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,property.getName());
}
}
json.writeEndArray();
}

Fixed version (ground truth):
private void writeComplexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  json.writeStartArray();
  for (  Object value : property.asCollection()) {
switch (property.getValueType()) {
case COLLECTION_COMPLEX:
      writeComplexValue(metadata,property,type,((ComplexValue)value).getValue(),selectedPaths,json);
    break;
default :
  throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,property.getName());
}
}
json.writeEndArray();
}
Program: 33169
Project: 33169
Buggy source:
protected void writeProperties(final EdmStructuredType type,final List<Property> properties,final SelectOption select,final JsonGenerator json) throws IOException, SerializerException {
  final boolean all=ExpandSelectHelper.isAll(select);
  final Set<String> selected=all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
  for (  final String propertyName : type.getPropertyNames()) {
    if (all || selected.contains(propertyName)) {
      final EdmProperty edmProperty=type.getStructuralProperty(propertyName);
      final Property property=findProperty(propertyName,properties);
      final Set<List<String>> selectedPaths=all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(),propertyName);
      writeProperty(edmProperty,property,selectedPaths,json);
    }
  }
}

Fixed version (ground truth):
protected void writeProperties(final ServiceMetadata metadata,final EdmStructuredType type,final List<Property> properties,final SelectOption select,final JsonGenerator json) throws IOException, SerializerException {
  final boolean all=ExpandSelectHelper.isAll(select);
  final Set<String> selected=all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
  for (  final String propertyName : type.getPropertyNames()) {
    if (all || selected.contains(propertyName)) {
      final EdmProperty edmProperty=type.getStructuralProperty(propertyName);
      final Property property=findProperty(propertyName,properties);
      final Set<List<String>> selectedPaths=all || edmProperty.isPrimitive() ? null : ExpandSelectHelper.getSelectedPaths(select.getSelectItems(),propertyName);
      writeProperty(metadata,edmProperty,property,selectedPaths,json);
    }
  }
}
Program: 33170
Project: 33170
Buggy source:
private void writePropertyValue(final EdmProperty edmProperty,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  final EdmType type=edmProperty.getType();
  try {
    if (edmProperty.isPrimitive() || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType)type,property,edmProperty.isNullable(),edmProperty.getMaxLength(),edmProperty.getPrecision(),edmProperty.getScale(),edmProperty.isUnicode(),json);
      }
 else {
        writePrimitive((EdmPrimitiveType)type,property,edmProperty.isNullable(),edmProperty.getMaxLength(),edmProperty.getPrecision(),edmProperty.getScale(),edmProperty.isUnicode(),json);
      }
    }
 else     if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection((EdmComplexType)type,property,selectedPaths,json);
      }
 else {
        writeComplexValue((EdmComplexType)type,property.asComplex().getValue(),selectedPaths,json);
      }
    }
 else {
      throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,edmProperty.getName());
    }
  }
 catch (  final EdmPrimitiveTypeException e) {
    throw new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,edmProperty.getName(),property.getValue().toString());
  }
}

Fixed version (ground truth):
private void writePropertyValue(final ServiceMetadata metadata,final EdmProperty edmProperty,final Property property,final Set<List<String>> selectedPaths,final JsonGenerator json) throws IOException, SerializerException {
  final EdmType type=edmProperty.getType();
  try {
    if (edmProperty.isPrimitive() || type.getKind() == EdmTypeKind.ENUM || type.getKind() == EdmTypeKind.DEFINITION) {
      if (edmProperty.isCollection()) {
        writePrimitiveCollection((EdmPrimitiveType)type,property,edmProperty.isNullable(),edmProperty.getMaxLength(),edmProperty.getPrecision(),edmProperty.getScale(),edmProperty.isUnicode(),json);
      }
 else {
        writePrimitive((EdmPrimitiveType)type,property,edmProperty.isNullable(),edmProperty.getMaxLength(),edmProperty.getPrecision(),edmProperty.getScale(),edmProperty.isUnicode(),json);
      }
    }
 else     if (property.isComplex()) {
      if (edmProperty.isCollection()) {
        writeComplexCollection(metadata,(EdmComplexType)type,property,selectedPaths,json);
      }
 else {
        writeComplexValue(metadata,property,(EdmComplexType)type,property.asComplex().getValue(),selectedPaths,json);
      }
    }
 else {
      throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,edmProperty.getName());
    }
  }
 catch (  final EdmPrimitiveTypeException e) {
    throw new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.WRONG_PROPERTY_VALUE,edmProperty.getName(),property.getValue().toString());
  }
}
Program: 33171
Project: 33171
Buggy source:
protected void writeComplexValue(final ServiceMetadata metadata,final EdmComplexType type,final List<Property> properties,final Set<List<String>> selectedPaths,final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
  for (  final String propertyName : type.getPropertyNames()) {
    final Property property=findProperty(propertyName,properties);
    if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths,propertyName)) {
      writeProperty(metadata,(EdmProperty)type.getProperty(propertyName),property,selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths,propertyName),writer);
    }
  }
}

Fixed version (ground truth):
protected void writeComplexValue(final ServiceMetadata metadata,Property complexProperty,final EdmComplexType type,final List<Property> properties,final Set<List<String>> selectedPaths,final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
  final EdmComplexType resolvedType=resolveComplexType(metadata,type,complexProperty.getType());
  for (  final String propertyName : resolvedType.getPropertyNames()) {
    final Property property=findProperty(propertyName,properties);
    if (selectedPaths == null || ExpandSelectHelper.isSelected(selectedPaths,propertyName)) {
      writeProperty(metadata,(EdmProperty)resolvedType.getProperty(propertyName),property,selectedPaths == null ? null : ExpandSelectHelper.getReducedSelectedPaths(selectedPaths,propertyName),writer);
    }
  }
}
Program: 33172
Project: 33172
Buggy source:
private void writeComplexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final Set<List<String>> selectedPaths,final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
  for (  Object value : property.asCollection()) {
    writer.writeStartElement(METADATA,Constants.ELEM_ELEMENT,NS_METADATA);
    if (derivedComplexType(type,property.getType()) != null) {
      writer.writeAttribute(METADATA,NS_METADATA,Constants.ATTR_TYPE,property.getType());
    }
switch (property.getValueType()) {
case COLLECTION_COMPLEX:
      writeComplexValue(metadata,type,((ComplexValue)value).getValue(),selectedPaths,writer);
    break;
default :
  throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,property.getName());
}
writer.writeEndElement();
}
}

Fixed version (ground truth):
private void writeComplexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final Set<List<String>> selectedPaths,final XMLStreamWriter writer) throws XMLStreamException, SerializerException {
  for (  Object value : property.asCollection()) {
    writer.writeStartElement(METADATA,Constants.ELEM_ELEMENT,NS_METADATA);
    if (derivedComplexType(type,property.getType()) != null) {
      writer.writeAttribute(METADATA,NS_METADATA,Constants.ATTR_TYPE,property.getType());
    }
switch (property.getValueType()) {
case COLLECTION_COMPLEX:
      writeComplexValue(metadata,property,type,((ComplexValue)value).getValue(),selectedPaths,writer);
    break;
default :
  throw new SerializerException("String_Node_Str",SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE,property.getName());
}
writer.writeEndElement();
}
}
Program: 33173
Project: 33173
Buggy source:
private String derivedComplexType(final EdmComplexType baseType,final String definedType) throws SerializerException {
  String derived=baseType.getFullQualifiedName().getFullQualifiedNameAsString();
  if (derived.equals(definedType)) {
    return null;
  }
  return definedType;
}

Fixed version (ground truth):
private String derivedComplexType(final EdmComplexType baseType,final String definedType) throws SerializerException {
  String base=baseType.getFullQualifiedName().getFullQualifiedNameAsString();
  if (base.equals(definedType)) {
    return null;
  }
  return definedType;
}
Program: 33175
Project: 33175
Buggy source:
private EntityCollection createESCompComp(final Edm edm,final OData odata){
  EntityCollection entityCollection=new EntityCollection();
  Entity entity=new Entity();
  entity.addProperty(createPrimitive("String_Node_Str",(short)1));
  entity.addProperty(createComplex("String_Node_Str",createComplex("String_Node_Str",createPrimitive("String_Node_Str",(short)123),createPrimitive("String_Node_Str","String_Node_Str"))));
  entityCollection.getEntities().add(entity);
  entity=new Entity();
  entity.addProperty(createPrimitive("String_Node_Str",(short)2));
  entity.addProperty(createComplex("String_Node_Str",createComplex("String_Node_Str",createPrimitive("String_Node_Str",(short)987),createPrimitive("String_Node_Str","String_Node_Str"))));
  entityCollection.getEntities().add(entity);
  setEntityType(entityCollection,edm.getEntityType(EntityTypeProvider.nameETCompComp));
  createEntityId(edm,odata,"String_Node_Str",entityCollection);
  return entityCollection;
}

Fixed version (ground truth):
private EntityCollection createESCompComp(final Edm edm,final OData odata){
  EntityCollection entityCollection=new EntityCollection();
  Entity entity=new Entity();
  entity.addProperty(createPrimitive("String_Node_Str",(short)1));
  entity.addProperty(createComplex("String_Node_Str",createComplex("String_Node_Str",createPrimitive("String_Node_Str",(short)123),createPrimitive("String_Node_Str","String_Node_Str"))));
  entityCollection.getEntities().add(entity);
  entity=new Entity();
  entity.addProperty(createPrimitive("String_Node_Str",(short)2));
  entity.addProperty(createComplex("String_Node_Str",ComplexTypeProvider.nameCTCompCompExtended.getFullQualifiedNameAsString(),createComplex("String_Node_Str",createPrimitive("String_Node_Str",(short)987),createPrimitive("String_Node_Str","String_Node_Str")),createPrimitive("String_Node_Str",getDateTime(2012,12,3,0,0,0))));
  entityCollection.getEntities().add(entity);
  setEntityType(entityCollection,edm.getEntityType(EntityTypeProvider.nameETCompComp));
  createEntityId(edm,odata,"String_Node_Str",entityCollection);
  return entityCollection;
}
Program: 33176
Project: 33176
Buggy source:
protected static Property createComplex(final String name,final Property... properties){
  ComplexValue complexValue=new ComplexValue();
  for (  final Property property : properties) {
    complexValue.getValue().add(property);
  }
  return new Property(null,name,ValueType.COMPLEX,complexValue);
}

Fixed version (ground truth):
protected static Property createComplex(final String name,final String type,final Property... properties){
  ComplexValue complexValue=new ComplexValue();
  for (  final Property property : properties) {
    complexValue.getValue().add(property);
  }
  return new Property(type,name,ValueType.COMPLEX,complexValue);
}
Program: 33178
Project: 33178
Buggy source:
@Test public void selectComplex() throws Exception {
  final EdmEntitySet edmEntitySet=entityContainer.getEntitySet("String_Node_Str");
  final EdmEntityType entityType=edmEntitySet.getEntityType();
  final EntityCollection entitySet=data.readAll(edmEntitySet);
  final SelectOption select=ExpandSelectMock.mockSelectOption(Collections.singletonList(ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str","String_Node_Str")));
  InputStream result=serializer.entityCollection(metadata,entityType,entitySet,EntityCollectionSerializerOptions.with().contextURL(ContextURL.with().entitySet(edmEntitySet).selectList(helper.buildContextURLSelectList(entityType,null,select)).build()).select(select).build()).getContent();
  final String resultString=IOUtils.toString(result);
  Assert.assertEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",resultString);
}

Fixed version (ground truth):
@Test public void selectComplex() throws Exception {
  final EdmEntitySet edmEntitySet=entityContainer.getEntitySet("String_Node_Str");
  final EdmEntityType entityType=edmEntitySet.getEntityType();
  final EntityCollection entitySet=data.readAll(edmEntitySet);
  final SelectOption select=ExpandSelectMock.mockSelectOption(Collections.singletonList(ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str","String_Node_Str")));
  InputStream result=serializer.entityCollection(metadata,entityType,entitySet,EntityCollectionSerializerOptions.with().contextURL(ContextURL.with().entitySet(edmEntitySet).selectList(helper.buildContextURLSelectList(entityType,null,select)).build()).select(select).build()).getContent();
  final String resultString=IOUtils.toString(result);
  Assert.assertEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",resultString);
}
Program: 33179
Project: 33179
Buggy source:
@Test public void selectComplexTwice() throws Exception {
  final EdmEntitySet edmEntitySet=entityContainer.getEntitySet("String_Node_Str");
  final EdmEntityType entityType=edmEntitySet.getEntityType();
  final EntityCollection entitySet=data.readAll(edmEntitySet);
  final SelectOption select=ExpandSelectMock.mockSelectOption(Arrays.asList(ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str","String_Node_Str"),ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str")));
  final String resultString=IOUtils.toString(serializer.entityCollection(metadata,entityType,entitySet,EntityCollectionSerializerOptions.with().contextURL(ContextURL.with().entitySet(edmEntitySet).selectList(helper.buildContextURLSelectList(entityType,null,select)).build()).select(select).build()).getContent());
  Assert.assertEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",resultString);
}

Fixed version (ground truth):
@Test public void selectComplexTwice() throws Exception {
  final EdmEntitySet edmEntitySet=entityContainer.getEntitySet("String_Node_Str");
  final EdmEntityType entityType=edmEntitySet.getEntityType();
  final EntityCollection entitySet=data.readAll(edmEntitySet);
  final SelectOption select=ExpandSelectMock.mockSelectOption(Arrays.asList(ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str","String_Node_Str"),ExpandSelectMock.mockSelectItem(edmEntitySet,"String_Node_Str","String_Node_Str")));
  final String resultString=IOUtils.toString(serializer.entityCollection(metadata,entityType,entitySet,EntityCollectionSerializerOptions.with().contextURL(ContextURL.with().entitySet(edmEntitySet).selectList(helper.buildContextURLSelectList(entityType,null,select)).build()).select(select).build()).getContent());
  Assert.assertEquals("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",resultString);
}
Program: 33180
Project: 33180
Buggy source:
void read(XMLEventReader reader,StartElement element,T t,String... names) throws XMLStreamException {
  while (reader.hasNext()) {
    XMLEvent event=reader.peek();
    if (!parseAnnotations) {
      event=skipAnnotations(reader,event);
    }
    if (!event.isStartElement() && !event.isEndElement()) {
      reader.nextEvent();
      continue;
    }
    boolean hit=false;
    for (    String name : names) {
      if (event.isStartElement()) {
        element=event.asStartElement();
        if (element.getName().getLocalPart().equals(name)) {
          reader.nextEvent();
          build(reader,element,t,name);
          hit=true;
          break;
        }
      }
      if (event.isEndElement()) {
        EndElement e=event.asEndElement();
        if (e.getName().getLocalPart().equals(name)) {
          reader.nextEvent();
          hit=true;
          break;
        }
      }
    }
    if (!hit) {
      break;
    }
  }
}

Fixed version (ground truth):
void read(XMLEventReader reader,StartElement element,T t,String... names) throws XMLStreamException {
  while (reader.hasNext()) {
    XMLEvent event=reader.peek();
    if (!parseAnnotations) {
      XMLEvent eventBefore=event;
      event=skipAnnotations(reader,event);
      if (eventBefore != event) {
        continue;
      }
    }
    if (!event.isStartElement() && !event.isEndElement()) {
      reader.nextEvent();
      continue;
    }
    boolean hit=false;
    for (    String name : names) {
      if (event.isStartElement()) {
        element=event.asStartElement();
        if (element.getName().getLocalPart().equals(name)) {
          reader.nextEvent();
          build(reader,element,t,name);
          hit=true;
          break;
        }
      }
      if (event.isEndElement()) {
        EndElement e=event.asEndElement();
        if (e.getName().getLocalPart().equals(name)) {
          reader.nextEvent();
          hit=true;
          break;
        }
      }
    }
    if (!hit) {
      break;
    }
  }
}
Program: 33182
Project: 33182
Buggy source:
/** 
 * @param name of the parameter
 */
public void setName(final String name){
  this.name=name;
}

Fixed version (ground truth):
/** 
 * Sets the name of the parameter.
 * @param name of the parameter
 */
public void setName(final String name){
  this.name=name;
}
Program: 33183
Project: 33183
Buggy source:
/** 
 * @return name of the parameter
 */
public String getName(){
  return name;
}

Fixed version (ground truth):
/** 
 * Gets the name of the parameter.
 * @return name of the parameter
 */
public String getName(){
  return name;
}
Program: 33184
Project: 33184
Buggy source:
/** 
 * Get the value in its entity representation or null if it is not based on an entity ValueType
 * @return entity representation or null if it is not based on an entity ValueType
 */
public Entity asEntity(){
  if (isCollection()) {
    return null;
  }
  return isEntity() ? (Entity)getValue() : null;
}

Fixed version (ground truth):
/** 
 * Gets the value in its entity representation or null if it is not based on an entity value type.
 * @return entity representation or null if it is not based on an entity value type
 */
public Entity asEntity(){
  return isEntity() && !isCollection() ? (Entity)getValue() : null;
}
Program: 33185
Project: 33185
Buggy source:
/** 
 * Check if Valuable contains a ENTITY or COLLECTION_ENTITY ValueType
 * @return true if ValueType is a ENTITY or COLLECTION_ENTITY, otherwise false
 */
public boolean isEntity(){
  if (isCollection()) {
    return getValueType().getBaseType() == ValueType.ENTITY;
  }
  return getValueType() == ValueType.ENTITY;
}

Fixed version (ground truth):
/** 
 * Checks whether this parameter value is of the value type ENTITY or COLLECTION_ENTITY.
 * @return true if the value type is ENTITY or COLLECTION_ENTITY, otherwise false
 */
public boolean isEntity(){
  return getValueType() == ValueType.ENTITY || getValueType() == ValueType.COLLECTION_ENTITY;
}
Program: 33186
Project: 33186
Buggy source:
/** 
 * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType
 * @return geospatial representation or null if it is not based on a geospatial ValueType
 */
public Geospatial asGeospatial(){
  if (isCollection()) {
    return null;
  }
  return isGeospatial() ? (Geospatial)value : null;
}

Fixed version (ground truth):
/** 
 * Get the value in its geospatial representation or null if it is not based on a geospatial ValueType
 * @return geospatial representation or null if it is not based on a geospatial ValueType
 */
public Geospatial asGeospatial(){
  return isGeospatial() && !isCollection() ? (Geospatial)value : null;
}
Program: 33187
Project: 33187
Buggy source:
/** 
 * Get the value in its enum representation or null if it is not based on a enum ValueType
 * @return enum representation or null if it is not based on a enum ValueType
 */
public Object asEnum(){
  if (isCollection()) {
    return null;
  }
  return isEnum() ? value : null;
}

Fixed version (ground truth):
/** 
 * Get the value in its enum representation or null if it is not based on a enum ValueType
 * @return enum representation or null if it is not based on a enum ValueType
 */
public Object asEnum(){
  return isEnum() && !isCollection() ? value : null;
}
Program: 33188
Project: 33188
Buggy source:
/** 
 * Check if Valuable contains a ENUM or COLLECTION_ENUM ValueType
 * @return true if ValueType is a ENUM or COLLECTION_ENUM, otherwise false
 */
public boolean isEnum(){
  if (isCollection()) {
    return valueType.getBaseType() == ValueType.ENUM;
  }
  return valueType == ValueType.ENUM;
}

Fixed version (ground truth):
/** 
 * Check if Valuable contains a ENUM or COLLECTION_ENUM ValueType
 * @return true if ValueType is a ENUM or COLLECTION_ENUM, otherwise false
 */
public boolean isEnum(){
  return valueType == ValueType.ENUM || valueType == ValueType.COLLECTION_ENUM;
}
Program: 33189
Project: 33189
Buggy source:
/** 
 * Get the value in its complex representation or null if it is not based on a complex ValueType
 * @return primitive complex or null if it is not based on a complex ValueType
 */
public ComplexValue asComplex(){
  if (isCollection()) {
    return null;
  }
  return isComplex() ? (ComplexValue)value : null;
}

Fixed version (ground truth):
/** 
 * Get the value in its complex representation or null if it is not based on a complex ValueType
 * @return primitive complex or null if it is not based on a complex ValueType
 */
public ComplexValue asComplex(){
  return isComplex() && !isCollection() ? (ComplexValue)value : null;
}
Program: 33190
Project: 33190
Buggy source:
/** 
 * Check if Valuable contains a GEOSPATIAL or COLLECTION_GEOSPATIAL ValueType
 * @return true if ValueType is a GEOSPATIAL or COLLECTION_GEOSPATIAL, otherwise false
 */
public boolean isGeospatial(){
  if (isCollection()) {
    return valueType.getBaseType() == ValueType.GEOSPATIAL;
  }
  return valueType == ValueType.GEOSPATIAL;
}

Fixed version (ground truth):
/** 
 * Check if Valuable contains a GEOSPATIAL or COLLECTION_GEOSPATIAL ValueType
 * @return true if ValueType is a GEOSPATIAL or COLLECTION_GEOSPATIAL, otherwise false
 */
public boolean isGeospatial(){
  return valueType == ValueType.GEOSPATIAL || valueType == ValueType.COLLECTION_GEOSPATIAL;
}
Program: 33191
Project: 33191
Buggy source:
/** 
 * Get the value in its primitive representation or null if it is not based on a primitive ValueType
 * @return primitive representation or null if it is not based on a primitive ValueType
 */
public Object asPrimitive(){
  if (isCollection()) {
    return null;
  }
  return isPrimitive() ? value : null;
}

Fixed version (ground truth):
/** 
 * Get the value in its primitive representation or null if it is not based on a primitive ValueType
 * @return primitive representation or null if it is not based on a primitive ValueType
 */
public Object asPrimitive(){
  return isPrimitive() && !isCollection() ? value : null;
}
Program: 33192
Project: 33192
Buggy source:
/** 
 * Check if Valuable contains a PRIMITIVE or COLLECTION_PRIMITIVE ValueType
 * @return true if ValueType is a PRIMITIVE or COLLECTION_PRIMITIVE, otherwise false
 */
public boolean isPrimitive(){
  if (isCollection()) {
    return valueType.getBaseType() == ValueType.PRIMITIVE;
  }
  return valueType == ValueType.PRIMITIVE;
}

Fixed version (ground truth):
/** 
 * Check if Valuable contains a PRIMITIVE or COLLECTION_PRIMITIVE ValueType
 * @return true if ValueType is a PRIMITIVE or COLLECTION_PRIMITIVE, otherwise false
 */
public boolean isPrimitive(){
  return valueType == ValueType.PRIMITIVE || valueType == ValueType.COLLECTION_PRIMITIVE;
}
Program: 33193
Project: 33193
Buggy source:
/** 
 * Check if Valuable contains a COMPLEX or COLLECTION_COMPLEX ValueType
 * @return true if ValueType is a COMPLEX or COLLECTION_COMPLEX, otherwise false
 */
public boolean isComplex(){
  if (isCollection()) {
    return valueType.getBaseType() == ValueType.COMPLEX;
  }
  return valueType == ValueType.COMPLEX;
}

Fixed version (ground truth):
/** 
 * Check if Valuable contains a COMPLEX or COLLECTION_COMPLEX ValueType
 * @return true if ValueType is a COMPLEX or COLLECTION_COMPLEX, otherwise false
 */
public boolean isComplex(){
  return valueType == ValueType.COMPLEX || valueType == ValueType.COLLECTION_COMPLEX;
}
Program: 33194
Project: 33194
Buggy source:
/** 
 * pct-encoded-unescaped = "%" ( "0" / "1" / "3" / "4" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG / "%" "2" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) / "%" "5" ( DIGIT / "A" / "B" / "D" / "E" / "F" ) HEXDIG = DIGIT / A-to-F
 * @param character which is checked
 * @return true if character is allowed
 */
private static boolean isPctEncodedUnescaped(char character){
  String hex=Integer.toHexString((int)character);
  char aschar[]=hex.toCharArray();
  if (aschar[0] == '%') {
    if (aschar[1] == '2') {
      return aschar[2] != '2' && isHexDigit(aschar[2]);
    }
 else     if (aschar[1] == '5') {
      return aschar[2] != 'C' && isHexDigit(aschar[2]);
    }
 else     if (isHexDigit(aschar[1])) {
      return isHexDigit(aschar[2]);
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * pct-encoded-unescaped = "%" ( "0" / "1" / "3" / "4" / "6" / "7" / "8" / "9" / A-to-F ) HEXDIG / "%" "2" ( "0" / "1" / "3" / "4" / "5" / "6" / "7" / "8" / "9" / A-to-F ) / "%" "5" ( DIGIT / "A" / "B" / "D" / "E" / "F" ) HEXDIG = DIGIT / A-to-F
 * @param character which is checked
 * @return true if character is allowed
 */
private static boolean isPctEncodedUnescaped(char character){
  String hex=Integer.toHexString(character);
  char aschar[]=hex.toCharArray();
  if (aschar[0] == '%') {
    if (aschar[1] == '2') {
      return aschar[2] != '2' && isHexDigit(aschar[2]);
    }
 else     if (aschar[1] == '5') {
      return aschar[2] != 'C' && isHexDigit(aschar[2]);
    }
 else     if (isHexDigit(aschar[1])) {
      return isHexDigit(aschar[2]);
    }
  }
  return false;
}
Program: 33198
Project: 33198
Buggy source:
@Override public List<CsdlAliasInfo> getAliasInfos() throws ODataException {
  return Arrays.asList(new CsdlAliasInfo().setAlias("String_Node_Str").setNamespace(nameSpace),new CsdlAliasInfo().setAlias("String_Node_Str").setNamespace(CORE_VOCABULARY_NAMESPACE));
}

Fixed version (ground truth):
@Override public List<CsdlAliasInfo> getAliasInfos() throws ODataException {
  return Arrays.asList(new CsdlAliasInfo().setAlias(SchemaProvider.NAMESPACE_ALIAS).setNamespace(SchemaProvider.NAMESPACE),new CsdlAliasInfo().setAlias("String_Node_Str").setNamespace(TermProvider.CORE_VOCABULARY_NAMESPACE));
}
Program: 33199
Project: 33199
Buggy source:
public SchemaProvider(final EdmTechProvider prov){
  this.prov=prov;
}

Fixed version (ground truth):
public SchemaProvider(final CsdlEdmProvider prov){
  this.prov=prov;
}
Program: 33201
Project: 33201
Buggy source:
public State finish(){
  this.finished=true;
  return this;
}

Fixed version (ground truth):
public State finish(Token token){
  this.token=token;
  return finish();
}
Program: 33202
Project: 33202
Buggy source:
public SearchExpressionState(){
  super(null);
}

Fixed version (ground truth):
public SearchExpressionState(String initLiteral){
  super(null,initLiteral);
}
Program: 33203
Project: 33203
Buggy source:
@Override public State nextChar(char c){
  if (isWhitespace(c)) {
    return allowed(c);
  }
 else   if (c == CHAR_O) {
    return new OrState(c);
  }
 else   if (c == CHAR_A) {
    return new AndState(c);
  }
 else {
    finish();
    return new SearchExpressionState().init(c);
  }
}

Fixed version (ground truth):
@Override public State nextChar(char c){
  if (!noneRws && isWhitespace(c)) {
    return allowed(c);
  }
 else   if (c == CHAR_O) {
    noneRws=true;
    return allowed(c);
  }
 else   if (literal.length() == 1 && c == CHAR_R) {
    return allowed(c);
  }
 else   if (literal.length() == 2 && isWhitespace(c)) {
    finish(Token.OR);
    return new BeforeSearchExpressionRwsState();
  }
 else   if (c == CHAR_A) {
    noneRws=true;
    return allowed(c);
  }
 else   if (literal.length() == 1 && c == CHAR_N) {
    return allowed(c);
  }
 else   if (literal.length() == 2 && c == CHAR_D) {
    return allowed(c);
  }
 else   if (literal.length() == 3 && isWhitespace(c)) {
    finish(Token.AND);
    return new BeforeSearchExpressionRwsState();
  }
 else   if (noneRws) {
    finish(Token.AND);
    return new SearchWordState(this);
  }
 else {
    finish(Token.AND);
    return new SearchExpressionState(literal.toString()).init(c);
  }
}
Program: 33204
Project: 33204
Buggy source:
@Test public void parseSpecial() throws Exception {
  SearchTokenizer tokenizer=new SearchTokenizer();
  List<SearchQueryToken> result;
  Iterator<SearchQueryToken> it;
  result=tokenizer.tokenize("String_Node_Str");
  log(result.toString());
  it=result.iterator();
  Assert.assertEquals(NOT,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  Assert.assertEquals(AND,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  result=tokenizer.tokenize("String_Node_Str");
  log(result.toString());
  it=result.iterator();
  Assert.assertEquals(WORD,it.next().getToken());
  Assert.assertEquals(AND,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  SearchValidator.init("String_Node_Str").addExpected(WORD,AND,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,OR,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,OR,WORD).validate();
}

Fixed version (ground truth):
@Test public void parseSpecial() throws Exception {
  SearchTokenizer tokenizer=new SearchTokenizer();
  List<SearchQueryToken> result;
  Iterator<SearchQueryToken> it;
  result=tokenizer.tokenize("String_Node_Str");
  log(result.toString());
  it=result.iterator();
  Assert.assertEquals(NOT,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  Assert.assertEquals(AND,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  result=tokenizer.tokenize("String_Node_Str");
  log(result.toString());
  it=result.iterator();
  Assert.assertEquals(WORD,it.next().getToken());
  Assert.assertEquals(AND,it.next().getToken());
  Assert.assertEquals(WORD,it.next().getToken());
  SearchValidator.init("String_Node_Str").addExpected(WORD,AND,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,AND,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,AND,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,OR,WORD).validate();
  SearchValidator.init("String_Node_Str").addExpected(WORD,OR,WORD).validate();
}
Program: 33205
Project: 33205
Buggy source:
private Object getRawValueFromClient(EdmProperty edmProperty) throws DeserializerException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream(1024);
  byte[] buffer=new byte[1024];
  int read=0;
  do {
    try {
      read=IOUtils.read(getODataRequest().getBody(),buffer,0,1024);
      bos.write(buffer,0,read);
      if (read < 1024) {
        break;
      }
    }
 catch (    IOException e) {
      new DeserializerException("String_Node_Str",SerializerException.MessageKeys.IO_EXCEPTION);
    }
  }
 while (true);
  return bos.toByteArray();
}

Fixed version (ground truth):
private Object getRawValueFromClient(EdmProperty edmProperty) throws DeserializerException {
  ByteArrayOutputStream bos=new ByteArrayOutputStream(1024);
  byte[] buffer=new byte[1024];
  int read=0;
  do {
    try {
      read=IOUtils.read(getODataRequest().getBody(),buffer,0,1024);
      bos.write(buffer,0,read);
      if (read < 1024) {
        break;
      }
    }
 catch (    IOException e) {
      throw new DeserializerException("String_Node_Str",SerializerException.MessageKeys.IO_EXCEPTION);
    }
  }
 while (true);
  return bos.toByteArray();
}
Program: 33206
Project: 33206
Buggy source:
public static String buildLocation(String baseURL,Entity entity,String enitySetName,EdmEntityType type){
  String location=baseURL + "String_Node_Str" + enitySetName+ "String_Node_Str";
  int i=0;
  boolean usename=type.getKeyPredicateNames().size() > 1;
  for (  String key : type.getKeyPredicateNames()) {
    if (i > 0) {
      location+="String_Node_Str";
    }
    i++;
    if (usename) {
      location+=(key + "String_Node_Str");
    }
    if (entity.getProperty(key).getType().equals("String_Node_Str")) {
      location=location + "String_Node_Str" + entity.getProperty(key).getValue().toString()+ "String_Node_Str";
    }
 else {
      location=location + entity.getProperty(key).getValue().toString();
    }
  }
  location+="String_Node_Str";
  return location;
}

Fixed version (ground truth):
public static String buildLocation(String baseURL,Entity entity,String enitySetName,EdmEntityType type){
  StringBuilder location=new StringBuilder();
  location.append(baseURL).append("String_Node_Str").append(enitySetName).append("String_Node_Str");
  int i=0;
  boolean usename=type.getKeyPredicateNames().size() > 1;
  for (  String key : type.getKeyPredicateNames()) {
    if (i > 0) {
      location.append("String_Node_Str");
    }
    i++;
    if (usename) {
      location.append(key).append("String_Node_Str");
    }
    if (entity.getProperty(key).getType().equals("String_Node_Str")) {
      location.append("String_Node_Str").append(entity.getProperty(key).getValue().toString()).append("String_Node_Str");
    }
 else {
      location.append(entity.getProperty(key).getValue().toString());
    }
  }
  location.append("String_Node_Str");
  return location.toString();
}
Program: 33207
Project: 33207
Buggy source:
private void collection(final Valuable valuable,final XMLEventReader reader,final StartElement start,final EdmProperty edmProperty) throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
  List<Object> values=new ArrayList<Object>();
  EdmType edmType=edmProperty.getType();
  boolean foundEndProperty=false;
  while (reader.hasNext() && !foundEndProperty) {
    final XMLEvent event=reader.nextEvent();
    if (event.isStartElement()) {
      if (edmType instanceof SingletonPrimitiveType) {
        values.add(primitive(reader,event.asStartElement(),edmProperty));
      }
 else       if (edmType instanceof EdmComplexType) {
        values.add(complex(reader,event.asStartElement(),(EdmComplexType)edmType));
      }
 else       if (edmType instanceof EdmEnumType) {
        values.add(readEnum(reader,event.asStartElement()));
      }
 else {
      }
    }
    if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
      foundEndProperty=true;
    }
  }
  valuable.setValue(getValueType(edmType,true),values);
}

Fixed version (ground truth):
private void collection(final Valuable valuable,final XMLEventReader reader,final StartElement start,final EdmProperty edmProperty) throws XMLStreamException, EdmPrimitiveTypeException, DeserializerException {
  List<Object> values=new ArrayList<Object>();
  EdmType edmType=edmProperty.getType();
  boolean foundEndProperty=false;
  while (reader.hasNext() && !foundEndProperty) {
    final XMLEvent event=reader.nextEvent();
    if (event.isStartElement()) {
      if (edmType instanceof SingletonPrimitiveType) {
        values.add(primitive(reader,event.asStartElement(),edmProperty));
      }
 else       if (edmType instanceof EdmComplexType) {
        values.add(complex(reader,event.asStartElement(),(EdmComplexType)edmType));
      }
 else       if (edmType instanceof EdmEnumType) {
        values.add(readEnum(reader,event.asStartElement()));
      }
    }
    if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
      foundEndProperty=true;
    }
  }
  valuable.setValue(getValueType(edmType,true),values);
}