nus-yam/ex-repair huggingface dataset:
Program: 33284
Project: 33284
Buggy source:
@Override public SerializerResult primitiveCollection(final ServiceMetadata metadata,final EdmPrimitiveType type,final Property property,final PrimitiveSerializerOptions options) throws SerializerException {
  CircleStreamBuffer buffer=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    buffer=new CircleStreamBuffer();
    JsonGenerator json=new JsonFactory().createGenerator(buffer.getOutputStream());
    json.writeStartObject();
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    json.writeFieldName(Constants.VALUE);
    writePrimitiveCollection(type,property,options == null ? null : options.isNullable(),options == null ? null : options.getMaxLength(),options == null ? null : options.getPrecision(),options == null ? null : options.getScale(),options == null ? null : options.isUnicode(),json);
    json.writeEndObject();
    json.close();
    buffer.getOutputStream().close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(buffer,cachedException);
  }
}

Fixed version (ground truth):
@Override public SerializerResult primitiveCollection(final ServiceMetadata metadata,final EdmPrimitiveType type,final Property property,final PrimitiveSerializerOptions 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);
    writePrimitiveCollection(type,property,options == null ? null : options.isNullable(),options == null ? null : options.getMaxLength(),options == null ? null : options.getPrecision(),options == null ? null : options.getScale(),options == null ? null : options.isUnicode(),json);
    json.writeEndObject();
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33285
Project: 33285
Buggy source:
@Override public SerializerResult reference(final ServiceMetadata metadata,final EdmEntitySet edmEntitySet,final Entity entity,final ReferenceSerializerOptions options) throws SerializerException {
  CircleStreamBuffer buffer=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    buffer=new CircleStreamBuffer();
    final UriHelper uriHelper=new UriHelperImpl();
    final JsonGenerator json=new JsonFactory().createGenerator(buffer.getOutputStream());
    json.writeStartObject();
    writeContextURL(contextURL,json);
    json.writeStringField(Constants.JSON_ID,uriHelper.buildCanonicalURL(edmEntitySet,entity));
    json.writeEndObject();
    json.close();
    buffer.getOutputStream().close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(buffer,cachedException);
  }
}

Fixed version (ground truth):
@Override public SerializerResult reference(final ServiceMetadata metadata,final EdmEntitySet edmEntitySet,final Entity entity,final ReferenceSerializerOptions options) throws SerializerException {
  OutputStream outputStream=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    CircleStreamBuffer buffer=new CircleStreamBuffer();
    final UriHelper uriHelper=new UriHelperImpl();
    outputStream=buffer.getOutputStream();
    final JsonGenerator json=new JsonFactory().createGenerator(outputStream);
    json.writeStartObject();
    writeContextURL(contextURL,json);
    json.writeStringField(Constants.JSON_ID,uriHelper.buildCanonicalURL(edmEntitySet,entity));
    json.writeEndObject();
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33286
Project: 33286
Buggy source:
@Override public SerializerResult entityCollection(final ServiceMetadata metadata,final EdmEntityType entityType,final EntityCollection entitySet,final EntityCollectionSerializerOptions options) throws SerializerException {
  CircleStreamBuffer buffer=null;
  SerializerException cachedException=null;
  try {
    buffer=new CircleStreamBuffer();
    JsonGenerator json=new JsonFactory().createGenerator(buffer.getOutputStream());
    json.writeStartObject();
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    if (options != null && options.getCount() != null && options.getCount().getValue()) {
      writeCount(entitySet,json);
    }
    json.writeFieldName(Constants.VALUE);
    if (options == null) {
      writeEntitySet(metadata,entityType,entitySet,null,null,false,json);
    }
 else {
      writeEntitySet(metadata,entityType,entitySet,options.getExpand(),options.getSelect(),options.onlyReferences(),json);
    }
    writeNextLink(entitySet,json);
    json.close();
    buffer.getOutputStream().close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(buffer,cachedException);
  }
}

Fixed version (ground truth):
@Override public SerializerResult entityCollection(final ServiceMetadata metadata,final EdmEntityType entityType,final EntityCollection entitySet,final EntityCollectionSerializerOptions options) throws SerializerException {
  OutputStream outputStream=null;
  SerializerException cachedException=null;
  try {
    CircleStreamBuffer buffer=new CircleStreamBuffer();
    outputStream=buffer.getOutputStream();
    JsonGenerator json=new JsonFactory().createGenerator(outputStream);
    json.writeStartObject();
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    if (options != null && options.getCount() != null && options.getCount().getValue()) {
      writeCount(entitySet,json);
    }
    json.writeFieldName(Constants.VALUE);
    if (options == null) {
      writeEntitySet(metadata,entityType,entitySet,null,null,false,json);
    }
 else {
      writeEntitySet(metadata,entityType,entitySet,options.getExpand(),options.getSelect(),options.onlyReferences(),json);
    }
    writeNextLink(entitySet,json);
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33287
Project: 33287
Buggy source:
@Override public SerializerResult complexCollection(final ServiceMetadata metadata,final EdmComplexType type,final Property property,final ComplexSerializerOptions options) throws SerializerException {
  CircleStreamBuffer buffer=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    buffer=new CircleStreamBuffer();
    JsonGenerator json=new JsonFactory().createGenerator(buffer.getOutputStream());
    json.writeStartObject();
    writeContextURL(contextURL,json);
    writeMetadataETag(metadata,json);
    json.writeFieldName(Constants.VALUE);
    writeComplexCollection(type,property,null,json);
    json.writeEndObject();
    json.close();
    buffer.getOutputStream().close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(buffer,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(type,property,null,json);
    json.writeEndObject();
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33290
Project: 33290
Buggy source:
@Override public SerializerResult entity(final ServiceMetadata metadata,final EdmEntityType entityType,final Entity entity,final EntitySerializerOptions options) throws SerializerException {
  CircleStreamBuffer buffer=null;
  SerializerException cachedException=null;
  try {
    final ContextURL contextURL=checkContextURL(options == null ? null : options.getContextURL());
    buffer=new CircleStreamBuffer();
    JsonGenerator json=new JsonFactory().createGenerator(buffer.getOutputStream());
    writeEntity(metadata,entityType,entity,contextURL,options == null ? null : options.getExpand(),options == null ? null : options.getSelect(),options == null ? false : options.onlyReferences(),json);
    json.close();
    buffer.getOutputStream().close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(buffer,cachedException);
  }
}

Fixed version (ground truth):
@Override public SerializerResult entity(final ServiceMetadata metadata,final EdmEntityType entityType,final Entity entity,final EntitySerializerOptions 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);
    writeEntity(metadata,entityType,entity,contextURL,options == null ? null : options.getExpand(),options == null ? null : options.getSelect(),options == null ? false : options.onlyReferences(),json);
    json.close();
    outputStream.close();
    return SerializerResultImpl.with().content(buffer.getInputStream()).build();
  }
 catch (  final IOException e) {
    cachedException=new SerializerException("String_Node_Str",e,SerializerException.MessageKeys.IO_EXCEPTION);
    throw cachedException;
  }
 finally {
    closeCircleStreamBufferOutput(outputStream,cachedException);
  }
}
Program: 33291
Project: 33291
Buggy source:
private void validateContentType(final ODataRequest request) throws BatchDeserializerException {
  BatchParserCommon.getContentType(request.getHeader(HttpHeader.CONTENT_TYPE),ContentType.MULTIPART_MIXED,0);
}

Fixed version (ground truth):
private void validateContentType(final ODataRequest request) throws BatchDeserializerException {
  BatchParserCommon.parseContentType(request.getHeader(HttpHeader.CONTENT_TYPE),ContentType.MULTIPART_MIXED,0);
}
Program: 33292
Project: 33292
Buggy source:
private boolean isContentTypeMultiPartMixed(final String contentType){
  try {
    BatchParserCommon.getContentType(contentType,ContentType.MULTIPART_MIXED,0);
    return true;
  }
 catch (  final BatchDeserializerException e) {
    return false;
  }
}

Fixed version (ground truth):
private boolean isContentTypeMultiPartMixed(final String contentType){
  try {
    BatchParserCommon.parseContentType(contentType,ContentType.MULTIPART_MIXED,0);
    return true;
  }
 catch (  final BatchDeserializerException e) {
    return false;
  }
}
Program: 33293
Project: 33293
Buggy source:
public static String getBoundary(final String contentType,final int line) throws BatchDeserializerException {
  final ContentType type=getContentType(contentType,ContentType.MULTIPART_MIXED,line);
  final Map<String,String> parameters=type.getParameters();
  for (  final Map.Entry<String,String> entries : parameters.entrySet()) {
    if (BOUNDARY.equalsIgnoreCase(entries.getKey())) {
      final String boundary=entries.getValue().trim();
      if (boundary.matches(PATTERN_BOUNDARY)) {
        return trimQuotes(boundary);
      }
 else {
        throw new BatchDeserializerException("String_Node_Str",BatchDeserializerException.MessageKeys.INVALID_BOUNDARY,Integer.toString(line));
      }
    }
  }
  throw new BatchDeserializerException("String_Node_Str",BatchDeserializerException.MessageKeys.MISSING_BOUNDARY_DELIMITER,Integer.toString(line));
}

Fixed version (ground truth):
public static String getBoundary(final String contentType,final int line) throws BatchDeserializerException {
  final ContentType type=parseContentType(contentType,ContentType.MULTIPART_MIXED,line);
  final Map<String,String> parameters=type.getParameters();
  for (  final Map.Entry<String,String> entries : parameters.entrySet()) {
    if (BOUNDARY.equalsIgnoreCase(entries.getKey())) {
      final String boundary=entries.getValue().trim();
      if (boundary.matches(PATTERN_BOUNDARY)) {
        return trimQuotes(boundary);
      }
 else {
        throw new BatchDeserializerException("String_Node_Str",BatchDeserializerException.MessageKeys.INVALID_BOUNDARY,Integer.toString(line));
      }
    }
  }
  throw new BatchDeserializerException("String_Node_Str",BatchDeserializerException.MessageKeys.MISSING_BOUNDARY_DELIMITER,Integer.toString(line));
}
Program: 33294
Project: 33294
Buggy source:
public static void validateContentType(final Header headers,final ContentType expected) throws BatchDeserializerException {
  final List<String> contentTypes=headers.getHeaders(HttpHeader.CONTENT_TYPE);
  if (contentTypes.isEmpty()) {
    throw new BatchDeserializerException("String_Node_Str",MessageKeys.MISSING_CONTENT_TYPE,Integer.toString(headers.getLineNumber()));
  }
  if (BatchParserCommon.getContentType(contentTypes.get(0),expected,headers.getLineNumber()) == null) {
    throw new BatchDeserializerException("String_Node_Str",MessageKeys.INVALID_CONTENT_TYPE,expected.toContentTypeString());
  }
}

Fixed version (ground truth):
public static void validateContentType(final Header headers,final ContentType expected) throws BatchDeserializerException {
  final List<String> contentTypes=headers.getHeaders(HttpHeader.CONTENT_TYPE);
  if (contentTypes.isEmpty()) {
    throw new BatchDeserializerException("String_Node_Str",MessageKeys.MISSING_CONTENT_TYPE,Integer.toString(headers.getLineNumber()));
  }
  BatchParserCommon.parseContentType(contentTypes.get(0),expected,headers.getLineNumber());
}
Program: 33295
Project: 33295
Buggy source:
public UriInfoImpl setQueryOptions(final List<QueryOptionImpl> list){
  for (  QueryOptionImpl item : list) {
    if (item instanceof SystemQueryOptionImpl) {
      setSystemQueryOption((SystemQueryOptionImpl)item);
    }
 else     if (item instanceof CustomQueryOptionImpl) {
      addCustomQueryOption(item);
    }
  }
  return this;
}

Fixed version (ground truth):
public UriInfoImpl setQueryOptions(final List<QueryOptionImpl> list){
  for (  QueryOptionImpl item : list) {
    if (item instanceof SystemQueryOptionImpl) {
      setSystemQueryOption((SystemQueryOptionImpl)item);
    }
 else     if (item instanceof CustomQueryOptionImpl) {
      addCustomQueryOption((CustomQueryOptionImpl)item);
    }
  }
  return this;
}
Program: 33296
Project: 33296
Buggy source:
public void addCustomQueryOption(final QueryOptionImpl item){
  customQueryOptions.add((CustomQueryOptionImpl)item);
  if (item.getName().startsWith("String_Node_Str")) {
    aliasToValue.put(item.getName(),item.getText());
  }
}

Fixed version (ground truth):
public void addCustomQueryOption(final CustomQueryOptionImpl item){
  customQueryOptions.add(item);
  if (item.getName().startsWith("String_Node_Str")) {
    aliasToValue.put(item.getName(),item.getText());
  }
}
Program: 33297
Project: 33297
Buggy source:
public void showTokens(final String input,final List<? extends Token> list){
  boolean first=true;
  System.out.println("String_Node_Str" + input);
  String nL="String_Node_Str";
  String out="String_Node_Str" + nL;
  for (  Token token : list) {
    if (!first) {
      out+="String_Node_Str";
      first=false;
    }
    int index=token.getType();
    if (index != -1) {
      out+="String_Node_Str" + token.getText() + "String_Node_Str"+ "String_Node_Str"+ UriLexer.tokenNames[index]+ nL;
    }
 else {
      out+="String_Node_Str" + token.getText() + "String_Node_Str"+ "String_Node_Str"+ index+ nL;
    }
  }
  out+=']';
  System.out.println("String_Node_Str" + out);
  return;
}

Fixed version (ground truth):
public void showTokens(final String input,final List<? extends Token> list){
  boolean first=true;
  System.out.println("String_Node_Str" + input);
  String nL="String_Node_Str";
  StringBuilder out=new StringBuilder("String_Node_Str").append(nL);
  for (  Token token : list) {
    if (!first) {
      out.append("String_Node_Str");
      first=false;
    }
    int index=token.getType();
    out.append("String_Node_Str").append(token.getText()).append("String_Node_Str").append("String_Node_Str");
    if (index != -1) {
      out.append(UriLexer.tokenNames[index]);
    }
 else {
      out.append(index);
    }
    out.append(nL);
  }
  out.append(']');
  System.out.println("String_Node_Str" + out.toString());
}
Program: 33298
Project: 33298
Buggy source:
public static List<String> split(final String input,final char c){
  List<String> list=new LinkedList<String>();
  int start=0;
  int end=-1;
  while ((end=input.indexOf(c,start)) >= 0) {
    list.add(input.substring(start,end));
    start=end + 1;
  }
  list.add(input.substring(start));
  return list;
}

Fixed version (ground truth):
static List<String> split(final String input,final char c,boolean skipEmpty){
  if (skipEmpty && (input.isEmpty() || input.length() == 1 && input.charAt(0) == c)) {
    return Collections.emptyList();
  }
  List<String> list=new LinkedList<String>();
  int start=0;
  int end;
  while ((end=input.indexOf(c,start)) >= 0) {
    if (skipEmpty) {
      if (start != end) {
        list.add(input.substring(start,end));
      }
    }
 else {
      list.add(input.substring(start,end));
    }
    start=end + 1;
  }
  if (skipEmpty) {
    if (input.charAt(input.length() - 1) != c) {
      list.add(input.substring(start));
    }
  }
 else {
    list.add(input.substring(start));
  }
  return list;
}
Program: 33299
Project: 33299
Buggy source:
private static List<RawUri.QueryOption> splitOptions(final String queryOptionString){
  if (queryOptionString == null) {
    return Collections.<RawUri.QueryOption>emptyList();
  }
  List<RawUri.QueryOption> queryOptionList=new ArrayList<RawUri.QueryOption>();
  for (  String option : split(queryOptionString,'&')) {
    if (option.length() != 0) {
      final List<String> pair=splitFirst(option,'=');
      queryOptionList.add(new RawUri.QueryOption(pair.get(0),pair.get(1)));
    }
  }
  return queryOptionList;
}

Fixed version (ground truth):
private static List<RawUri.QueryOption> splitOptions(final String queryOptionString){
  if (queryOptionString == null) {
    return Collections.emptyList();
  }
  List<RawUri.QueryOption> queryOptionList=new ArrayList<RawUri.QueryOption>();
  for (  String option : splitSkipEmpty(queryOptionString,'&')) {
    final List<String> pair=splitFirst(option,'=');
    queryOptionList.add(new RawUri.QueryOption(pair.get(0),pair.get(1)));
  }
  return queryOptionList;
}
Program: 33300
Project: 33300
Buggy source:
private static List<String> splitPath(final String path,final int skipSegments){
  List<String> list=split(path,'/');
  while (list.remove("String_Node_Str")) {
  }
  return skipSegments > 0 ? list.subList(skipSegments,list.size()) : list;
}

Fixed version (ground truth):
private static List<String> splitPath(final String path,final int skipSegments){
  List<String> list=splitSkipEmpty(path,'/');
  return skipSegments > 0 ? list.subList(skipSegments,list.size()) : list;
}
Program: 33302
Project: 33302
Buggy source:
public ExpandItemImpl setSystemQueryOption(final SystemQueryOptionImpl sysItem){
  if (sysItem.getKind() == SystemQueryOptionKind.EXPAND) {
    expandOption=(ExpandOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.FILTER) {
    filterOption=(FilterOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.COUNT) {
    inlineCountOption=(CountOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.ORDERBY) {
    orderByOption=(OrderByOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.SEARCH) {
    searchOption=(SearchOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.SELECT) {
    selectOption=(SelectOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.SKIP) {
    skipOption=(SkipOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.TOP) {
    topOption=(TopOptionImpl)sysItem;
  }
 else   if (sysItem.getKind() == SystemQueryOptionKind.LEVELS) {
    levelsExpandOption=(LevelsExpandOption)sysItem;
  }
  return this;
}

Fixed version (ground truth):
public ExpandItemImpl setSystemQueryOption(final SystemQueryOptionImpl sysItem){
  if (sysItem instanceof ExpandOptionImpl) {
    expandOption=(ExpandOptionImpl)sysItem;
  }
 else   if (sysItem instanceof FilterOptionImpl) {
    filterOption=(FilterOptionImpl)sysItem;
  }
 else   if (sysItem instanceof CountOptionImpl) {
    inlineCountOption=(CountOptionImpl)sysItem;
  }
 else   if (sysItem instanceof OrderByOptionImpl) {
    orderByOption=(OrderByOptionImpl)sysItem;
  }
 else   if (sysItem instanceof SearchOptionImpl) {
    searchOption=(SearchOptionImpl)sysItem;
  }
 else   if (sysItem instanceof SelectOptionImpl) {
    selectOption=(SelectOptionImpl)sysItem;
  }
 else   if (sysItem instanceof SkipOptionImpl) {
    skipOption=(SkipOptionImpl)sysItem;
  }
 else   if (sysItem instanceof TopOptionImpl) {
    topOption=(TopOptionImpl)sysItem;
  }
 else   if (sysItem instanceof LevelsExpandOption) {
    levelsExpandOption=(LevelsExpandOption)sysItem;
  }
  return this;
}
Program: 33303
Project: 33303
Buggy source:
private void validatePropertyOperations(final UriInfo uriInfo,final HttpMethod method) throws UriValidationException {
  final List<UriResource> parts=uriInfo.getUriResourceParts();
  final UriResource last=parts.size() > 0 ? parts.get(parts.size() - 1) : null;
  final UriResource previous=parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null && (last.getKind() == UriResourceKind.primitiveProperty || last.getKind() == UriResourceKind.complexProperty || last.getKind() == UriResourceKind.value && previous.getKind() == UriResourceKind.primitiveProperty)) {
    final EdmProperty property=((UriResourceProperty)(last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("String_Node_Str",UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD,method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("String_Node_Str",UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD,method.toString());
    }
  }
}

Fixed version (ground truth):
private void validatePropertyOperations(final UriInfo uriInfo,final HttpMethod method) throws UriValidationException {
  final List<UriResource> parts=uriInfo.getUriResourceParts();
  final UriResource last=parts.size() > 0 ? parts.get(parts.size() - 1) : null;
  final UriResource previous=parts.size() > 1 ? parts.get(parts.size() - 2) : null;
  if (last != null && (last.getKind() == UriResourceKind.primitiveProperty || last.getKind() == UriResourceKind.complexProperty || (last.getKind() == UriResourceKind.value && previous != null && previous.getKind() == UriResourceKind.primitiveProperty))) {
    final EdmProperty property=((UriResourceProperty)(last.getKind() == UriResourceKind.value ? previous : last)).getProperty();
    if (method == HttpMethod.PATCH && property.isCollection()) {
      throw new UriValidationException("String_Node_Str",UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD,method.toString());
    }
    if (method == HttpMethod.DELETE && !property.isNullable()) {
      throw new UriValidationException("String_Node_Str",UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD,method.toString());
    }
  }
}
Program: 33304
Project: 33304
Buggy source:
private void validateNoQueryOptionsForHttpMethod(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
  if (!uriInfo.getSystemQueryOptions().isEmpty()) {
    String options="String_Node_Str";
    for (    SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
      options=options + option.getName() + "String_Node_Str";
    }
    throw new UriValidationException("String_Node_Str" + options + "String_Node_Str"+ httpMethod,UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD,options,httpMethod.toString());
  }
}

Fixed version (ground truth):
private void validateNoQueryOptionsForHttpMethod(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
  if (!uriInfo.getSystemQueryOptions().isEmpty()) {
    StringBuilder options=new StringBuilder();
    for (    SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
      options.append(option.getName()).append("String_Node_Str");
    }
    throw new UriValidationException("String_Node_Str" + options.toString() + "String_Node_Str"+ httpMethod,UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD,options.toString(),httpMethod.toString());
  }
}
Program: 33305
Project: 33305
Buggy source:
private boolean isAction(final UriInfo uriInfo){
  List<UriResource> uriResourceParts=uriInfo.getUriResourceParts();
  if (!uriResourceParts.isEmpty()) {
    return UriResourceKind.action == uriResourceParts.get(uriResourceParts.size() - 1).getKind();
  }
  return false;
}

Fixed version (ground truth):
private boolean isAction(final UriInfo uriInfo){
  List<UriResource> uriResourceParts=uriInfo.getUriResourceParts();
  if (uriResourceParts.isEmpty()) {
    return false;
  }
  return UriResourceKind.action == uriResourceParts.get(uriResourceParts.size() - 1).getKind();
}
Program: 33306
Project: 33306
Buggy source:
@Override protected Map<String,EdmSchema> createSchemas(){
  try {
    final Map<String,EdmSchema> providerSchemas=new LinkedHashMap<String,EdmSchema>();
    for (    CsdlSchema schema : provider.getSchemas()) {
      providerSchemas.put(schema.getNamespace(),new EdmSchemaImpl(this,provider,schema));
    }
    return providerSchemas;
  }
 catch (  ODataException e) {
    throw new EdmException(e);
  }
}

Fixed version (ground truth):
@Override protected Map<String,EdmSchema> createSchemas(){
  try {
    final Map<String,EdmSchema> providerSchemas=new LinkedHashMap<String,EdmSchema>();
    List<CsdlSchema> localSchemas=provider.getSchemas();
    if (localSchemas != null) {
      for (      CsdlSchema schema : localSchemas) {
        providerSchemas.put(schema.getNamespace(),new EdmSchemaImpl(this,provider,schema));
      }
    }
    return providerSchemas;
  }
 catch (  ODataException e) {
    throw new EdmException(e);
  }
}
Program: 33307
Project: 33307
Buggy source:
private InputStream wrapInJson(final List<DebugTab> parts) throws IOException {
  CircleStreamBuffer csb=new CircleStreamBuffer();
  JsonGenerator gen=new JsonFactory().createGenerator(csb.getOutputStream(),JsonEncoding.UTF8);
  gen.writeStartObject();
  DebugTab requestInfo=parts.get(0);
  gen.writeFieldName(requestInfo.getName().toLowerCase(Locale.ROOT));
  requestInfo.appendJson(gen);
  DebugTab responseInfo=parts.get(1);
  gen.writeFieldName(responseInfo.getName().toLowerCase(Locale.ROOT));
  responseInfo.appendJson(gen);
  gen.writeFieldName("String_Node_Str");
  gen.writeStartObject();
  gen.writeStringField("String_Node_Str",getVersion());
  for (  DebugTab part : parts.subList(2,parts.size())) {
    gen.writeFieldName(part.getName().toLowerCase(Locale.ROOT));
    part.appendJson(gen);
  }
  gen.writeEndObject();
  gen.writeEndObject();
  gen.close();
  csb.closeWrite();
  return csb.getInputStream();
}

Fixed version (ground truth):
private InputStream wrapInJson(final List<DebugTab> parts) throws IOException {
  CircleStreamBuffer csb=new CircleStreamBuffer();
  IOException cachedException=null;
  try {
    JsonGenerator gen=new JsonFactory().createGenerator(csb.getOutputStream(),JsonEncoding.UTF8);
    gen.writeStartObject();
    DebugTab requestInfo=parts.get(0);
    gen.writeFieldName(requestInfo.getName().toLowerCase(Locale.ROOT));
    requestInfo.appendJson(gen);
    DebugTab responseInfo=parts.get(1);
    gen.writeFieldName(responseInfo.getName().toLowerCase(Locale.ROOT));
    responseInfo.appendJson(gen);
    gen.writeFieldName("String_Node_Str");
    gen.writeStartObject();
    gen.writeStringField("String_Node_Str",getVersion());
    for (    DebugTab part : parts.subList(2,parts.size())) {
      gen.writeFieldName(part.getName().toLowerCase(Locale.ROOT));
      part.appendJson(gen);
    }
    gen.writeEndObject();
    gen.writeEndObject();
    gen.close();
    csb.getOutputStream().close();
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (csb != null && csb.getOutputStream() != null) {
      try {
        csb.getOutputStream().close();
      }
 catch (      IOException e) {
        if (cachedException != null) {
          throw cachedException;
        }
 else {
          throw e;
        }
      }
    }
  }
  return csb.getInputStream();
}
Program: 33308
Project: 33308
Buggy source:
private void appendSelectItemJson(JsonGenerator gen,SelectItem selectItem) throws IOException {
  String selectedProperty="String_Node_Str";
  if (selectItem.isStar()) {
    if (selectItem.getAllOperationsInSchemaNameSpace() == null) {
      selectedProperty="String_Node_Str";
    }
 else {
      selectedProperty=selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + "String_Node_Str";
    }
  }
 else {
    boolean first=true;
    for (    UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) {
      if (!first) {
        selectedProperty=selectedProperty + "String_Node_Str";
      }
      selectedProperty=resourcePart.toString();
    }
  }
  gen.writeString(selectedProperty);
}

Fixed version (ground truth):
private void appendSelectItemJson(JsonGenerator gen,SelectItem selectItem) throws IOException {
  String selectedProperty="String_Node_Str";
  if (selectItem.isStar()) {
    if (selectItem.getAllOperationsInSchemaNameSpace() == null) {
      selectedProperty="String_Node_Str";
    }
 else {
      selectedProperty=selectItem.getAllOperationsInSchemaNameSpace().getFullQualifiedNameAsString() + "String_Node_Str";
    }
  }
 else {
    boolean first=true;
    for (    UriResource resourcePart : selectItem.getResourcePath().getUriResourceParts()) {
      if (!first) {
        selectedProperty=selectedProperty + "String_Node_Str";
      }
      selectedProperty=resourcePart.toString();
      first=false;
    }
  }
  gen.writeString(selectedProperty);
}
Program: 33309
Project: 33309
Buggy source:
private String getJsonString() throws IOException {
  CircleStreamBuffer csb=new CircleStreamBuffer();
  JsonGenerator gen=new JsonFactory().createGenerator(csb.getOutputStream(),JsonEncoding.UTF8).setPrettyPrinter(new DefaultPrettyPrinter());
  appendJson(gen);
  gen.close();
  csb.closeWrite();
  return IOUtils.toString(csb.getInputStream());
}

Fixed version (ground truth):
private String getJsonString() throws IOException {
  CircleStreamBuffer csb=new CircleStreamBuffer();
  IOException cachedException=null;
  try {
    JsonGenerator json=new JsonFactory().createGenerator(csb.getOutputStream(),JsonEncoding.UTF8).setPrettyPrinter(new DefaultPrettyPrinter());
    appendJson(json);
    json.close();
    csb.getOutputStream().close();
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (csb != null && csb.getOutputStream() != null) {
      try {
        csb.getOutputStream().close();
      }
 catch (      IOException e) {
        if (cachedException != null) {
          throw cachedException;
        }
 else {
          throw e;
        }
      }
    }
  }
  try {
    String jsonString=IOUtils.toString(csb.getInputStream());
    csb.getInputStream().close();
    return jsonString;
  }
 catch (  IOException e) {
    throw e;
  }
 finally {
    if (csb != null && csb.getInputStream() != null) {
      try {
        csb.getInputStream().close();
      }
 catch (      IOException e) {
        if (cachedException != null) {
          throw cachedException;
        }
 else {
          throw e;
        }
      }
    }
  }
}
Program: 33310
Project: 33310
Buggy source:
private void validateForHttpMethod(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
  RowIndexForHttpMethod row=rowIndexForHttpMethod(httpMethod);
  for (  SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
    ColumnIndex col=colIndex(option.getKind());
    if (!decisionMatrixForHttpMethod[row.getIndex()][col.getIndex()]) {
      throw new UriValidationException("String_Node_Str" + option.getName() + "String_Node_Str"+ httpMethod,UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD,option.getName(),httpMethod.toString());
    }
  }
}

Fixed version (ground truth):
private void validateForHttpMethod(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
switch (httpMethod) {
case POST:
    if (!isAction(uriInfo)) {
      validateNoQueryOptionsForHttpMethod(uriInfo,httpMethod);
    }
  break;
case DELETE:
if (!isReferences(uriInfo)) {
  validateNoQueryOptionsForHttpMethod(uriInfo,httpMethod);
}
 else {
  for (  SystemQueryOption option : uriInfo.getSystemQueryOptions()) {
    if (SystemQueryOptionKind.ID != option.getKind()) {
      throw new UriValidationException("String_Node_Str" + option.getName() + "String_Node_Str"+ httpMethod,UriValidationException.MessageKeys.SYSTEM_QUERY_OPTION_NOT_ALLOWED_FOR_HTTP_METHOD,option.getName(),httpMethod.toString());
    }
  }
}
break;
case PUT:
case PATCH:
validateNoQueryOptionsForHttpMethod(uriInfo,httpMethod);
break;
default :
throw new UriValidationException("String_Node_Str" + httpMethod,UriValidationException.MessageKeys.UNSUPPORTED_HTTP_METHOD,httpMethod.toString());
}
}
Program: 33311
Project: 33311
Buggy source:
public void validate(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
  validateForHttpMethod(uriInfo,httpMethod);
  validateQueryOptions(uriInfo);
  validateKeyPredicates(uriInfo);
  validatePropertyOperations(uriInfo,httpMethod);
}

Fixed version (ground truth):
public void validate(final UriInfo uriInfo,final HttpMethod httpMethod) throws UriValidationException {
  if (HttpMethod.GET != httpMethod) {
    validateForHttpMethod(uriInfo,httpMethod);
  }
  validateQueryOptions(uriInfo);
  validateKeyPredicates(uriInfo);
  validatePropertyOperations(uriInfo,httpMethod);
}
Program: 33312
Project: 33312
Buggy source:
/** 
 * Add references (relationships) to Entity.
 * @param request
 * @param entityETag - entity etag to match before add operation, "*" allows all.
 * @param idReferences - references to add
 * @param response - return always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void addReference(DataRequest request,String entityETag,List<URI> idReferences,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;

Fixed version (ground truth):
/** 
 * Add references (relationships) to Entity. This is always on collection valued navigation property
 * @param request
 * @param entityETag - entity etag to match before add operation, "*" allows all.
 * @param referenceId - references to add
 * @param response - return always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void addReference(DataRequest request,String entityETag,URI referenceId,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;
Program: 33313
Project: 33313
Buggy source:
/** 
 * Update references (relationships) in an Entity
 * @param request
 * @param entityETag
 * @param referenceId
 * @param response - always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void updateReference(DataRequest request,String entityETag,URI referenceId,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;

Fixed version (ground truth):
/** 
 * Update references (relationships) in an Entity; This is always against single valued navigation property
 * @param request
 * @param entityETag
 * @param referenceId
 * @param response - always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void updateReference(DataRequest request,String entityETag,URI referenceId,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;
Program: 33314
Project: 33314
Buggy source:
/** 
 * Delete references (relationships) in an Entity
 * @param request
 * @param deleteId
 * @param entityETag
 * @param response - always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void deleteReference(DataRequest request,URI deleteId,String entityETag,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;

Fixed version (ground truth):
/** 
 * Delete references (relationships) in an Entity
 * @param request
 * @param deleteId; for collection valued navigation this will be non-null value; for single valuednavigation property, this will be null.
 * @param entityETag
 * @param response - always should be 204
 * @throws ODataTranslatedException
 * @throws ODataApplicationException
 */
void deleteReference(DataRequest request,URI deleteId,String entityETag,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException ;
Program: 33315
Project: 33315
Buggy source:
@Override public void addReference(DataRequest request,String entityETag,List<URI> idReferences,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
  selectProcessor(ReferenceProcessor.class).createReference(request.getODataRequest(),response.getODataResponse(),request.getUriInfo(),request.getResponseContentType());
}

Fixed version (ground truth):
@Override public void addReference(DataRequest request,String entityETag,URI referenceId,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
  selectProcessor(ReferenceProcessor.class).createReference(request.getODataRequest(),response.getODataResponse(),request.getUriInfo(),request.getResponseContentType());
}
Program: 33316
Project: 33316
Buggy source:
@Test public void testWriteReferenceCollection() throws Exception {
  String payload="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  final ServiceHandler handler=Mockito.mock(ServiceHandler.class);
  helpTest(handler,"String_Node_Str","String_Node_Str",payload,new TestResult(){
    @SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Override public void validate() throws Exception {
      ArgumentCaptor<DataRequest> arg1=ArgumentCaptor.forClass(DataRequest.class);
      ArgumentCaptor<String> arg2=ArgumentCaptor.forClass(String.class);
      ArgumentCaptor<List> arg3=ArgumentCaptor.forClass(List.class);
      ArgumentCaptor<NoContentResponse> arg4=ArgumentCaptor.forClass(NoContentResponse.class);
      Mockito.verify(handler).addReference(arg1.capture(),arg2.capture(),arg3.capture(),arg4.capture());
      DataRequest request=arg1.getValue();
      assertEquals("String_Node_Str",request.getResponseContentType().toContentTypeString());
    }
  }
);
}

Fixed version (ground truth):
@Test public void testWriteReferenceCollection() throws Exception {
  String payload="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  final ServiceHandler handler=Mockito.mock(ServiceHandler.class);
  helpTest(handler,"String_Node_Str","String_Node_Str",payload,new TestResult(){
    @SuppressWarnings({"String_Node_Str","String_Node_Str"}) @Override public void validate() throws Exception {
      ArgumentCaptor<DataRequest> arg1=ArgumentCaptor.forClass(DataRequest.class);
      ArgumentCaptor<String> arg2=ArgumentCaptor.forClass(String.class);
      ArgumentCaptor<URI> arg3=ArgumentCaptor.forClass(URI.class);
      ArgumentCaptor<NoContentResponse> arg4=ArgumentCaptor.forClass(NoContentResponse.class);
      Mockito.verify(handler).addReference(arg1.capture(),arg2.capture(),arg3.capture(),arg4.capture());
      DataRequest request=arg1.getValue();
      assertEquals("String_Node_Str",request.getResponseContentType().toContentTypeString());
    }
  }
);
}
Program: 33317
Project: 33317
Buggy source:
@Override public void addReference(DataRequest request,String entityETag,List<URI> references,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
  final EntityDetails details=process(request);
  try {
    for (    URI reference : references) {
      DataRequest bindingRequest=request.parseLink(reference);
      Entity linkEntity=this.dataModel.getEntity(bindingRequest.getEntitySet().getName(),bindingRequest.getKeyPredicates());
      this.dataModel.addNavigationLink(details.navigationProperty,details.entity,linkEntity);
    }
  }
 catch (  URISyntaxException e) {
    throw new ODataApplicationException(e.getMessage(),500,Locale.getDefault(),e);
  }
  response.writeNoContent();
}

Fixed version (ground truth):
@Override public void addReference(DataRequest request,String entityETag,URI referenceId,NoContentResponse response) throws ODataTranslatedException, ODataApplicationException {
  final EntityDetails details=process(request);
  try {
    DataRequest bindingRequest=request.parseLink(referenceId);
    Entity linkEntity=this.dataModel.getEntity(bindingRequest.getEntitySet().getName(),bindingRequest.getKeyPredicates());
    this.dataModel.addNavigationLink(details.navigationProperty,details.entity,linkEntity);
  }
 catch (  URISyntaxException e) {
    throw new ODataApplicationException(e.getMessage(),500,Locale.getDefault(),e);
  }
  response.writeNoContent();
}
Program: 33318
Project: 33318
Buggy source:
@Test public void testAddCollectionReferences() throws Exception {
  HttpResponse response=httpGET(baseURL + "String_Node_Str",200);
  JsonNode node=getJSONNode(response);
  assertTrue(node.get("String_Node_Str").isArray());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(0).get("String_Node_Str").asText());
  assertNull(((ArrayNode)node.get("String_Node_Str")).get(1));
  String payload="String_Node_Str" + "String_Node_Str" + baseURL + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  HttpPost postRequest=new HttpPost(baseURL + "String_Node_Str");
  postRequest.setEntity(new StringEntity(payload,ContentType.APPLICATION_JSON));
  response=httpSend(postRequest,204);
  response=httpGET(baseURL + "String_Node_Str",200);
  node=getJSONNode(response);
  assertTrue(node.get("String_Node_Str").isArray());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(0).get("String_Node_Str").asText());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(1).get("String_Node_Str").asText());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(2).get("String_Node_Str").asText());
}

Fixed version (ground truth):
@Test public void testAddCollectionReferences() throws Exception {
  HttpResponse response=httpGET(baseURL + "String_Node_Str",200);
  JsonNode node=getJSONNode(response);
  assertTrue(node.get("String_Node_Str").isArray());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(0).get("String_Node_Str").asText());
  assertNull(((ArrayNode)node.get("String_Node_Str")).get(1));
  String payload="String_Node_Str" + "String_Node_Str" + "String_Node_Str";
  HttpPost postRequest=new HttpPost(baseURL + "String_Node_Str");
  postRequest.setEntity(new StringEntity(payload,ContentType.APPLICATION_JSON));
  response=httpSend(postRequest,204);
  response=httpGET(baseURL + "String_Node_Str",200);
  node=getJSONNode(response);
  assertTrue(node.get("String_Node_Str").isArray());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(0).get("String_Node_Str").asText());
  assertEquals("String_Node_Str",((ArrayNode)node.get("String_Node_Str")).get(1).get("String_Node_Str").asText());
}