nus-yam/ex-repair huggingface dataset:
Program: 93474
Project: 93474
Buggy source:
private void embeddedDbs(RequestContext context,List<DBObject> embeddedData,boolean trailingSlash,String requestPath,Representation rep){
  embeddedData.stream().forEach((d) -> {
    Object _id=d.get("String_Node_Str");
    if (_id != null && (_id instanceof String || _id instanceof ObjectId)) {
      Representation nrep;
      if (trailingSlash) {
        nrep=new Representation(requestPath + _id.toString());
      }
 else {
        nrep=new Representation(requestPath + "String_Node_Str" + _id.toString());
      }
      if (context.isFullHalMode()) {
        DBRepresentationFactory.addSpecialProperties(nrep,RequestContext.TYPE.DB,d);
      }
      nrep.addProperties(d);
      rep.addRepresentation("String_Node_Str",nrep);
    }
 else {
      LOGGER.error("String_Node_Str",d);
    }
  }
);
}

Fixed version (ground truth):
private void embeddedDbs(RequestContext context,List<DBObject> embeddedData,boolean trailingSlash,String requestPath,Representation rep){
  embeddedData.stream().filter(d -> d != null).forEach((d) -> {
    Object _id=d.get("String_Node_Str");
    if (_id != null && (_id instanceof String || _id instanceof ObjectId)) {
      Representation nrep;
      if (trailingSlash) {
        nrep=new Representation(requestPath + _id.toString());
      }
 else {
        nrep=new Representation(requestPath + "String_Node_Str" + _id.toString());
      }
      if (context.isFullHalMode()) {
        DBRepresentationFactory.addSpecialProperties(nrep,RequestContext.TYPE.DB,d);
      }
      nrep.addProperties(d);
      rep.addRepresentation("String_Node_Str",nrep);
    }
 else {
      LOGGER.error("String_Node_Str",d);
    }
  }
);
}
Program: 93475
Project: 93475
Buggy source:
private void embeddedDocuments(List<DBObject> embeddedData,String requestPath,HttpServerExchange exchange,RequestContext context,Representation rep) throws IllegalQueryParamenterException {
  for (  DBObject d : embeddedData) {
    Object _id=d.get("String_Node_Str");
    if (RequestContext.isReservedResourceCollection(_id.toString())) {
      rep.addWarning("String_Node_Str" + requestPath + "String_Node_Str"+ _id.toString());
    }
 else {
      Representation nrep=new DocumentRepresentationFactory().getRepresentation(requestPath + "String_Node_Str" + _id.toString(),exchange,context,d);
      if (rep.getType() == RequestContext.TYPE.FILES_BUCKET) {
        if (context.isFullHalMode()) {
          DocumentRepresentationFactory.addSpecialProperties(nrep,TYPE.FILE,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
 else {
        if (context.isFullHalMode()) {
          DocumentRepresentationFactory.addSpecialProperties(nrep,TYPE.DOCUMENT,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
    }
  }
}

Fixed version (ground truth):
private void embeddedDocuments(List<DBObject> embeddedData,String requestPath,HttpServerExchange exchange,RequestContext context,Representation rep) throws IllegalQueryParamenterException {
  for (  DBObject d : embeddedData) {
    Object _id=d.get("String_Node_Str");
    if (RequestContext.isReservedResourceCollection(_id.toString())) {
      rep.addWarning("String_Node_Str" + requestPath + "String_Node_Str"+ _id.toString());
    }
 else {
      Representation nrep=new DocumentRepresentationFactory().getRepresentation(requestPath + "String_Node_Str" + _id.toString(),exchange,context,d);
      if (context.getType() == RequestContext.TYPE.FILES_BUCKET) {
        if (context.isFullHalMode()) {
          DocumentRepresentationFactory.addSpecialProperties(nrep,TYPE.FILE,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
 else {
        if (context.isFullHalMode()) {
          DocumentRepresentationFactory.addSpecialProperties(nrep,TYPE.DOCUMENT,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
    }
  }
}
Program: 93476
Project: 93476
Buggy source:
private void addLinkTemplates(final HttpServerExchange exchange,final RequestContext context,final Representation rep,final String requestPath){
  if (context.isParentAccessible()) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath)));
  }
  if (TYPE.FILES_BUCKET.equals(context.getType())) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath) + "String_Node_Str" + RequestContext.FS_FILES_SUFFIX,true));
    rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  }
 else   if (TYPE.COLLECTION.equals(context.getType())) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath) + "String_Node_Str",true));
    rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  }
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str" + context.getDBName()+ "String_Node_Str"+ context.getCollectionName()+ "String_Node_Str"));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str"));
}

Fixed version (ground truth):
private void addLinkTemplates(final RequestContext context,final Representation rep,final String requestPath){
  if (context.isParentAccessible()) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath)));
  }
  if (TYPE.FILES_BUCKET.equals(context.getType())) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath) + "String_Node_Str" + RequestContext.FS_FILES_SUFFIX,true));
    rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  }
 else   if (TYPE.COLLECTION.equals(context.getType())) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath) + "String_Node_Str",true));
    rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  }
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str" + context.getDBName()+ "String_Node_Str"+ context.getCollectionName()+ "String_Node_Str"));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str"));
}
Program: 93477
Project: 93477
Buggy source:
/** 
 * @param exchange
 * @param context
 * @param embeddedData
 * @param size
 * @return
 * @throws IllegalQueryParamenterException
 */
@Override public Representation getRepresentation(HttpServerExchange exchange,RequestContext context,List<DBObject> embeddedData,long size) throws IllegalQueryParamenterException {
  final String requestPath=buildRequestPath(exchange);
  final Representation rep=createRepresentation(exchange,context,requestPath);
  addProperties(rep,context);
  addSizeAndTotalPagesProperties(size,context,rep);
  addAggregationsLinks(context,rep,requestPath);
  addEmbeddedData(embeddedData,rep,requestPath,exchange,context);
  if (context.isFullHalMode()) {
    addSpecialProperties(rep,context.getType(),context.getCollectionProps());
    addPaginationLinks(exchange,context,size,rep);
    addLinkTemplates(exchange,context,rep,requestPath);
    rep.addLink(new Link("String_Node_Str","String_Node_Str",Configuration.RESTHEART_ONLINE_DOC_URL + "String_Node_Str",true),true);
  }
 else {
    rep.addLinkArray("String_Node_Str");
  }
  return rep;
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @param embeddedData
 * @param size
 * @return
 * @throws IllegalQueryParamenterException
 */
@Override public Representation getRepresentation(HttpServerExchange exchange,RequestContext context,List<DBObject> embeddedData,long size) throws IllegalQueryParamenterException {
  final String requestPath=buildRequestPath(exchange);
  final Representation rep=createRepresentation(exchange,context,requestPath);
  addProperties(rep,context);
  addSizeAndTotalPagesProperties(size,context,rep);
  addAggregationsLinks(context,rep,requestPath);
  addEmbeddedData(embeddedData,rep,requestPath,exchange,context);
  if (context.isFullHalMode()) {
    addSpecialProperties(rep,context.getType(),context.getCollectionProps());
    addPaginationLinks(exchange,context,size,rep);
    addLinkTemplates(context,rep,requestPath);
    rep.addLink(new Link("String_Node_Str","String_Node_Str",Configuration.RESTHEART_ONLINE_DOC_URL + "String_Node_Str",true),true);
  }
 else {
    rep.addLinkArray("String_Node_Str");
  }
  return rep;
}
Program: 93478
Project: 93478
Buggy source:
/** 
 * @param dbName
 * @return
 */
public boolean addDbProps(String dbName){
  if (!dbsDAO.existsDatabaseWithName(dbName)) {
    return false;
  }
  DBObject dbmd=dbsDAO.getDatabaseProperties(dbName,false);
  if (dbmd != null) {
    return false;
  }
  DBObject properties=new BasicDBObject();
  ObjectId timestamp=new ObjectId();
  Instant now=Instant.ofEpochSecond(timestamp.getTimestamp());
  properties.put("String_Node_Str","String_Node_Str");
  properties.put("String_Node_Str",now.toString());
  properties.put("String_Node_Str",timestamp);
  DBCollection coll=dbsDAO.getCollection(dbName,"String_Node_Str");
  coll.insert(properties);
  LOGGER.info("String_Node_Str",dbName);
  return true;
}

Fixed version (ground truth):
/** 
 * @param dbName
 * @return
 */
public boolean addDbProps(String dbName){
  if (!dbsDAO.doesDbExist(dbName)) {
    return false;
  }
  DBObject dbmd=dbsDAO.getDatabaseProperties(dbName,false);
  if (dbmd != null) {
    return false;
  }
  DBObject properties=new BasicDBObject();
  ObjectId timestamp=new ObjectId();
  Instant now=Instant.ofEpochSecond(timestamp.getTimestamp());
  properties.put("String_Node_Str","String_Node_Str");
  properties.put("String_Node_Str",now.toString());
  properties.put("String_Node_Str",timestamp);
  DBCollection coll=dbsDAO.getCollection(dbName,"String_Node_Str");
  coll.insert(properties);
  LOGGER.info("String_Node_Str",dbName);
  return true;
}
Program: 93479
Project: 93479
Buggy source:
/** 
 * @param exchange the url rewriting feature is implemented by the whatUriand whereUri parameters the exchange request path is rewritten replacing the whereUri string with the whatUri string the special whatUri value * means any resource: the whereUri is replaced with / example 1 whatUri = /mydb/mycollection whereUri = / then the requestPath / is rewritten to /mydb/mycollection example 2 whatUri = * whereUri = /data then the requestPath /data is rewritten to /
 * @param whereUri the uri to map to
 * @param whatUri the uri to map
 */
public RequestContext(HttpServerExchange exchange,String whereUri,String whatUri){
  this.whereUri=URLUtils.removeTrailingSlashes(whereUri);
  this.whatUri=whatUri;
  this.unmappedRequestUri=exchange.getRequestPath();
  this.mappedRequestUri=unmapUri(exchange.getRequestPath());
  this.pathTokens=this.mappedRequestUri.split(SLASH);
  this.type=selectRequestType(pathTokens);
  this.method=selectRequestMethod(exchange.getRequestMethod());
}

Fixed version (ground truth):
/** 
 * @param exchange the url rewriting feature is implemented by the whatUriand whereUri parameters the exchange request path is rewritten replacing the whereUri string with the whatUri string the special whatUri value * means any resource: the whereUri is replaced with / example 1 whatUri = /mydb/mycollection whereUri = / then the requestPath / is rewritten to /mydb/mycollection example 2 whatUri = * whereUri = /data then the requestPath /data is rewritten to /
 * @param whereUri the uri to map to
 * @param whatUri the uri to map
 */
public RequestContext(HttpServerExchange exchange,String whereUri,String whatUri){
  this.whereUri=URLUtils.removeTrailingSlashes(whereUri == null ? null : whereUri.startsWith("String_Node_Str") ? whereUri : "String_Node_Str" + whereUri);
  this.whatUri=URLUtils.removeTrailingSlashes(whatUri == null ? null : whatUri.startsWith("String_Node_Str") ? whatUri : "String_Node_Str" + whatUri);
  this.unmappedRequestUri=exchange.getRequestPath();
  this.mappedRequestUri=unmapUri(exchange.getRequestPath());
  this.pathTokens=this.mappedRequestUri.split(SLASH);
  this.type=selectRequestType(pathTokens);
  this.method=selectRequestMethod(exchange.getRequestMethod());
}
Program: 93480
Project: 93480
Buggy source:
/** 
 * given a mapped uri (/some/mapping/coll) returns the canonical uri (/db/coll) URLs are mapped to mongodb resources by using the mongo-mounts configuration properties
 * @param mappedUri
 * @return
 */
public final String unmapUri(String mappedUri){
  String ret=URLUtils.removeTrailingSlashes(mappedUri);
  if (whatUri.equals("String_Node_Str")) {
    if (!this.whereUri.equals(SLASH)) {
      ret=ret.replaceFirst("String_Node_Str" + this.whereUri,"String_Node_Str");
    }
  }
 else {
    ret=URLUtils.removeTrailingSlashes(ret.replaceFirst("String_Node_Str" + this.whereUri,this.whatUri));
  }
  if (ret.isEmpty()) {
    ret=SLASH;
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * given a mapped uri (/some/mapping/coll) returns the canonical uri (/db/coll) URLs are mapped to mongodb resources by using the mongo-mounts configuration properties
 * @param mappedUri
 * @return
 */
public final String unmapUri(String mappedUri){
  String ret=URLUtils.removeTrailingSlashes(mappedUri);
  if (whatUri.equals("String_Node_Str")) {
    if (!this.whereUri.equals(SLASH)) {
      ret=ret.replaceFirst("String_Node_Str" + this.whereUri,"String_Node_Str");
    }
  }
 else {
    if (!this.whereUri.equals(SLASH)) {
      ret=URLUtils.removeTrailingSlashes(ret.replaceFirst("String_Node_Str" + this.whereUri,this.whatUri));
    }
 else {
      ret=URLUtils.removeTrailingSlashes(URLUtils.removeTrailingSlashes(this.whatUri) + ret);
    }
  }
  if (ret.isEmpty()) {
    ret=SLASH;
  }
  return ret;
}
Program: 93481
Project: 93481
Buggy source:
private void embeddedCollections(final List<DBObject> embeddedData,final RequestContext context,final String requestPath,final Representation rep){
  embeddedData.stream().forEach((d) -> {
    Object _id=d.get("String_Node_Str");
    if (_id != null && _id instanceof String) {
      String id=(String)_id;
      Representation nrep=new Representation(requestPath + "String_Node_Str" + id);
      nrep.addProperties(d);
      if (id.endsWith(RequestContext.FS_FILES_SUFFIX)) {
        if (context.isFullHalMode()) {
          CollectionRepresentationFactory.addSpecialProperties(nrep,TYPE.FILES_BUCKET,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
 else {
        if (context.isFullHalMode()) {
          CollectionRepresentationFactory.addSpecialProperties(nrep,TYPE.COLLECTION,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
    }
 else {
      LOGGER.error("String_Node_Str",_id);
    }
  }
);
}

Fixed version (ground truth):
private void embeddedCollections(final List<DBObject> embeddedData,final RequestContext context,final String requestPath,final Representation rep){
  embeddedData.stream().forEach((d) -> {
    Object _id=d.get("String_Node_Str");
    if (_id != null && _id instanceof String) {
      String id=(String)_id;
      String rp=URLUtils.removeTrailingSlashes(requestPath);
      rp="String_Node_Str".equals(rp) ? "String_Node_Str" : rp;
      Representation nrep=new Representation(rp + "String_Node_Str" + id);
      nrep.addProperties(d);
      if (id.endsWith(RequestContext.FS_FILES_SUFFIX)) {
        if (context.isFullHalMode()) {
          CollectionRepresentationFactory.addSpecialProperties(nrep,TYPE.FILES_BUCKET,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
 else {
        if (context.isFullHalMode()) {
          CollectionRepresentationFactory.addSpecialProperties(nrep,TYPE.COLLECTION,d);
        }
        rep.addRepresentation("String_Node_Str",nrep);
      }
    }
 else {
      LOGGER.error("String_Node_Str",_id);
    }
  }
);
}
Program: 93482
Project: 93482
Buggy source:
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=getDatabase().deleteCollection(context.getDBName(),context.getCollectionName(),etag);
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
  LocalCachesSingleton.getInstance().invalidateCollection(context.getDBName(),context.getCollectionName());
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.injectEtagHeader(exchange,context.getCollectionProps());
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=getDatabase().deleteCollection(context.getDBName(),context.getCollectionName(),etag);
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
  LocalCachesSingleton.getInstance().invalidateCollection(context.getDBName(),context.getCollectionName());
}
Program: 93484
Project: 93484
Buggy source:
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=getDatabase().deleteDatabase(context.getDBName(),etag);
  exchange.setResponseCode(result.getHttpCode());
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
  LocalCachesSingleton.getInstance().invalidateDb(context.getDBName());
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.injectEtagHeader(exchange,context.getDbProps());
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=getDatabase().deleteDatabase(context.getDBName(),etag);
  exchange.setResponseCode(result.getHttpCode());
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
  LocalCachesSingleton.getInstance().invalidateDb(context.getDBName());
}
Program: 93486
Project: 93486
Buggy source:
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=this.documentDAO.deleteDocument(context.getDBName(),context.getCollectionName(),context.getDocumentId(),etag);
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  ObjectId etag=RequestHelper.getWriteEtag(exchange);
  if (etag == null) {
    ResponseHelper.injectEtagHeader(exchange,this.documentDAO.getDocumentEtag(context.getDBName(),context.getCollectionName(),context.getDocumentId()));
    ResponseHelper.endExchangeWithMessage(exchange,HttpStatus.SC_CONFLICT,"String_Node_Str" + Headers.IF_MATCH + "String_Node_Str");
    return;
  }
  OperationResult result=this.documentDAO.deleteDocument(context.getDBName(),context.getCollectionName(),context.getDocumentId(),etag);
  if (result.getEtag() != null) {
    exchange.getResponseHeaders().put(Headers.ETAG,result.getEtag().toString());
  }
  if (context.getWarnings() != null && !context.getWarnings().isEmpty()) {
    sendWarnings(result.getHttpCode(),exchange,context);
  }
 else {
    exchange.setResponseCode(result.getHttpCode());
  }
  exchange.endExchange();
}
Program: 93488
Project: 93488
Buggy source:
/** 
 * @param exchange
 * @param properties
 */
public static void injectEtagHeader(HttpServerExchange exchange,DBObject properties){
  if (properties == null) {
    return;
  }
  Object _etag=properties.get("String_Node_Str");
  if (ObjectId.isValid("String_Node_Str" + _etag)) {
    ObjectId etag=(ObjectId)_etag;
    exchange.getResponseHeaders().put(Headers.ETAG,etag.toString());
  }
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param properties
 */
public static void injectEtagHeader(HttpServerExchange exchange,DBObject properties){
  if (properties == null) {
    return;
  }
  Object _etag=properties.get("String_Node_Str");
  if (_etag == null || !(_etag instanceof ObjectId)) {
    return;
  }
  exchange.getResponseHeaders().put(Headers.ETAG,_etag.toString());
}
Program: 93489
Project: 93489
Buggy source:
/** 
 * @param channel
 * @return
 * @throws IOException
 */
public static String read(StreamSourceChannel channel) throws IOException {
  final int capacity=1024;
  ByteArrayOutputStream os=new ByteArrayOutputStream(capacity);
  ByteBuffer buf=ByteBuffer.allocate(capacity);
  while (Channels.readBlocking(channel,buf) != -1) {
    buf.flip();
    os.write(buf.array());
    buf.clear();
  }
  return new String(os.toByteArray(),CHARSET);
}

Fixed version (ground truth):
/** 
 * @param channel
 * @return
 * @throws IOException
 */
public static String read(StreamSourceChannel channel) throws IOException {
  final int capacity=1024;
  ByteArrayOutputStream os=new ByteArrayOutputStream(capacity);
  ByteBuffer buf=ByteBuffer.allocate(capacity);
  int read=Channels.readBlocking(channel,buf);
  while (read != -1) {
    buf.flip();
    os.write(buf.array(),0,read);
    buf.clear();
    read=Channels.readBlocking(channel,buf);
  }
  String ret=os.toString(CHARSET.name());
  return ret;
}
Program: 93490
Project: 93490
Buggy source:
private void addLinkTemplates(final HttpServerExchange exchange,final RequestContext context,final Representation rep,final String requestPath){
  if (context.isParentAccessible()) {
    rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath)));
  }
  rep.addLink(new Link("String_Node_Str",URLUtils.getParentPath(requestPath) + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str" + RequestContext.FS_FILES_SUFFIX,true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
}

Fixed version (ground truth):
private void addLinkTemplates(final HttpServerExchange exchange,final RequestContext context,final Representation rep,final String requestPath){
  String parentPath=URLUtils.getParentPath(requestPath);
  if (context.isParentAccessible()) {
    rep.addLink(new Link("String_Node_Str",parentPath));
  }
  if (parentPath.endsWith("String_Node_Str")) {
    rep.addLink(new Link("String_Node_Str",URLUtils.removeTrailingSlashes(URLUtils.getParentPath(requestPath)) + "String_Node_Str",true));
  }
 else {
    rep.addLink(new Link("String_Node_Str",URLUtils.removeTrailingSlashes(URLUtils.getParentPath(requestPath)) + "String_Node_Str",true));
  }
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str" + RequestContext.FS_FILES_SUFFIX,true));
  rep.addLink(new Link("String_Node_Str",requestPath + "String_Node_Str",true));
  rep.addLink(new Link("String_Node_Str","String_Node_Str",Configuration.RESTHEART_ONLINE_DOC_URL + "String_Node_Str",true),true);
}
Program: 93491
Project: 93491
Buggy source:
private void addEmbeddedData(List<DBObject> embeddedData,final Representation rep,final String requestPath,final HttpServerExchange exchange,final RequestContext context) throws IllegalQueryParamenterException {
  if (embeddedData != null) {
    addReturnedProperty(embeddedData,rep);
    if (!embeddedData.isEmpty()) {
      embeddedDocuments(embeddedData,requestPath,exchange,context,rep);
    }
  }
}

Fixed version (ground truth):
private void addEmbeddedData(List<DBObject> embeddedData,final Representation rep,final String requestPath,final HttpServerExchange exchange,final RequestContext context) throws IllegalQueryParamenterException {
  if (embeddedData != null) {
    addReturnedProperty(embeddedData,rep);
    if (!embeddedData.isEmpty()) {
      embeddedDocuments(embeddedData,requestPath,exchange,context,rep);
    }
  }
 else {
    rep.addProperty("String_Node_Str",0);
  }
}
Program: 93493
Project: 93493
Buggy source:
private void addEmbeddedData(final List<DBObject> embeddedData,final Representation rep,final String requestPath){
  if (embeddedData != null) {
    addReturnedProperty(embeddedData,rep);
    if (!embeddedData.isEmpty()) {
      embeddedCollections(embeddedData,requestPath,rep);
    }
  }
}

Fixed version (ground truth):
private void addEmbeddedData(final List<DBObject> embeddedData,final Representation rep,final String requestPath){
  if (embeddedData != null) {
    addReturnedProperty(embeddedData,rep);
    if (!embeddedData.isEmpty()) {
      embeddedCollections(embeddedData,requestPath,rep);
    }
  }
 else {
    rep.addProperty("String_Node_Str",0);
  }
}
Program: 93494
Project: 93494
Buggy source:
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  List<String> colls=getDatabase().getCollectionNames(getDatabase().getDB(context.getDBName()));
  List<DBObject> data=null;
  if (context.getPagesize() > 0 && (context.getHalMode() == RequestContext.HAL_MODE.F || context.getHalMode() == RequestContext.HAL_MODE.FULL)) {
    data=getDatabase().getData(context.getDBName(),colls,context.getPage(),context.getPagesize());
  }
  DBRepresentationFactory repf=new DBRepresentationFactory();
  Representation rep=repf.getRepresentation(exchange,context,data,getDatabase().getDBSize(colls));
  exchange.setResponseCode(HttpStatus.SC_OK);
  if (getNext() != null) {
    DBObject responseContent=rep.asDBObject();
    context.setResponseContent(responseContent);
    getNext().handleRequest(exchange,context);
  }
  repf.sendRepresentation(exchange,context,rep);
  exchange.endExchange();
}

Fixed version (ground truth):
/** 
 * @param exchange
 * @param context
 * @throws Exception
 */
@Override public void handleRequest(HttpServerExchange exchange,RequestContext context) throws Exception {
  List<String> colls=getDatabase().getCollectionNames(getDatabase().getDB(context.getDBName()));
  List<DBObject> data=null;
  if (context.getPagesize() > 0) {
    data=getDatabase().getData(context.getDBName(),colls,context.getPage(),context.getPagesize());
  }
  DBRepresentationFactory repf=new DBRepresentationFactory();
  Representation rep=repf.getRepresentation(exchange,context,data,getDatabase().getDBSize(colls));
  exchange.setResponseCode(HttpStatus.SC_OK);
  if (getNext() != null) {
    DBObject responseContent=rep.asDBObject();
    context.setResponseContent(responseContent);
    getNext().handleRequest(exchange,context);
  }
  repf.sendRepresentation(exchange,context,rep);
  exchange.endExchange();
}
Program: 93495
Project: 93495
Buggy source:
/** 
 * @param channel
 * @return
 * @throws IOException
 */
public static String read(StreamSourceChannel channel) throws IOException {
  StringBuilder content=new StringBuilder();
  ByteBuffer buf=ByteBuffer.allocate(128);
  while (Channels.readBlocking(channel,buf) != -1) {
    buf.flip();
    content.append(charset.decode(buf));
    buf.clear();
  }
  return content.toString();
}

Fixed version (ground truth):
/** 
 * @param channel
 * @return
 * @throws IOException
 */
public static String read(StreamSourceChannel channel) throws IOException {
  final int capacity=1024;
  ByteArrayOutputStream os=new ByteArrayOutputStream(capacity);
  ByteBuffer buf=ByteBuffer.allocate(capacity);
  while (Channels.readBlocking(channel,buf) != -1) {
    buf.flip();
    os.write(buf.array());
    buf.clear();
  }
  return new String(os.toByteArray(),CHARSET);
}
Program: 93497
Project: 93497
Buggy source:
/** 
 * Returs the DBCursor of the collection applying sorting and filtering.
 * @param coll the mongodb DBCollection object
 * @param sortBy the Deque collection of fields to use for sorting (prependfield name with - for descending sorting)
 * @param filters the filters to apply. it is a Deque collection of mongodbquery conditions.
 * @param keys 
 * @return
 * @throws JSONParseException
 */
DBCursor getCollectionDBCursor(DBCollection coll,Deque<String> sortBy,Deque<String> filters,Deque<String> keys) throws JSONParseException {
  DBObject sort=new BasicDBObject();
  if (sortBy == null || sortBy.isEmpty()) {
    sort.put("String_Node_Str",-1);
  }
 else {
    sortBy.stream().forEach((s) -> {
      String _s=s.trim();
      if (_s.startsWith("String_Node_Str")) {
        sort.put(_s.substring(1),-1);
      }
 else       if (_s.startsWith("String_Node_Str")) {
        sort.put(_s.substring(1),1);
      }
 else {
        sort.put(_s,1);
      }
    }
);
  }
  final BasicDBObject query=new BasicDBObject();
  if (filters != null) {
    filters.stream().forEach((    String f) -> {
      BSONObject filterQuery=(BSONObject)JSON.parse(f);
      query.putAll(filterQuery);
    }
);
  }
  final BasicDBObject fields=new BasicDBObject();
  if (keys != null) {
    keys.stream().forEach((    String f) -> {
      BSONObject keyQuery=(BSONObject)JSON.parse(f);
      fields.putAll(keyQuery);
    }
);
  }
  return coll.find(query,fields).sort(sort);
}

Fixed version (ground truth):
/** 
 * Returs the DBCursor of the collection applying sorting and filtering.
 * @param coll the mongodb DBCollection object
 * @param sortBy the Deque collection of fields to use for sorting (prependfield name with - for descending sorting)
 * @param filters the filters to apply. it is a Deque collection of mongodbquery conditions.
 * @param keys
 * @return
 * @throws JSONParseException
 */
DBCursor getCollectionDBCursor(DBCollection coll,Deque<String> sortBy,Deque<String> filters,Deque<String> keys) throws JSONParseException {
  DBObject sort=new BasicDBObject();
  if (sortBy == null || sortBy.isEmpty()) {
    sort.put("String_Node_Str",-1);
  }
 else {
    sortBy.stream().forEach((s) -> {
      String _s=s.trim();
      if (_s.startsWith("String_Node_Str")) {
        sort.put(_s.substring(1),-1);
      }
 else       if (_s.startsWith("String_Node_Str")) {
        sort.put(_s.substring(1),1);
      }
 else {
        sort.put(_s,1);
      }
    }
);
  }
  final BasicDBObject query=new BasicDBObject();
  if (filters != null) {
    filters.stream().forEach((    String f) -> {
      BSONObject filterQuery=(BSONObject)JSON.parse(f);
      query.putAll(filterQuery);
    }
);
  }
  final BasicDBObject fields=new BasicDBObject();
  if (keys != null) {
    keys.stream().forEach((    String f) -> {
      BSONObject keyQuery=(BSONObject)JSON.parse(f);
      fields.putAll(keyQuery);
    }
);
  }
  return coll.find(query,fields).sort(sort);
}
Program: 93498
Project: 93498
Buggy source:
private void populateCacheRandom(DBCursorPoolEntryKey key){
  executor.submit(() -> {
    Long size=collSizes.getLoading(key).get();
    int sliceWidht;
    int slices=0;
    int totalSlices=size.intValue() / SKIP_SLICE_RND_MIN_WIDTH + 1;
    if (totalSlices <= SKIP_SLICE_RND_MAX_CURSORS) {
      slices=totalSlices;
      sliceWidht=SKIP_SLICE_RND_MIN_WIDTH;
    }
 else {
      slices=SKIP_SLICE_RND_MAX_CURSORS;
      sliceWidht=size.intValue() / slices;
    }
    for (int slice=1; slice < slices; slice++) {
      int sliceSkips=(int)slice * sliceWidht;
      DBCursorPoolEntryKey sliceKey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,-1);
      long existing=getSliceHeight(sliceKey);
      for (long cont=1 - existing; cont > 0; cont--) {
        DBCursor cursor=dbsDAO.getCollectionDBCursor(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys());
        cursor.skip(sliceSkips);
        DBCursorPoolEntryKey newkey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,System.nanoTime());
        cache.put(newkey,cursor);
        LOGGER.debug("String_Node_Str",newkey);
      }
    }
  }
);
}

Fixed version (ground truth):
private void populateCacheRandom(DBCursorPoolEntryKey key){
  executor.submit(() -> {
    Long size=collSizes.getLoading(key).get();
    int sliceWidht;
    int slices;
    int totalSlices=size.intValue() / SKIP_SLICE_RND_MIN_WIDTH + 1;
    if (totalSlices <= SKIP_SLICE_RND_MAX_CURSORS) {
      slices=totalSlices;
      sliceWidht=SKIP_SLICE_RND_MIN_WIDTH;
    }
 else {
      slices=SKIP_SLICE_RND_MAX_CURSORS;
      sliceWidht=size.intValue() / slices;
    }
    for (int slice=1; slice < slices; slice++) {
      int sliceSkips=(int)slice * sliceWidht;
      DBCursorPoolEntryKey sliceKey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,-1);
      long existing=getSliceHeight(sliceKey);
      if (existing == 0) {
        DBCursor cursor=dbsDAO.getCollectionDBCursor(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys());
        cursor.skip(sliceSkips).limit(1000 + sliceWidht);
        cursor.hasNext();
        DBCursorPoolEntryKey newkey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,System.nanoTime());
        cache.put(newkey,cursor);
        LOGGER.debug("String_Node_Str",newkey);
      }
    }
  }
);
}
Program: 93499
Project: 93499
Buggy source:
private void populateCacheLinear(DBCursorPoolEntryKey key){
  if (key.getSkipped() < SKIP_SLICE_LINEAR_WIDTH) {
    return;
  }
  int firstSlice=key.getSkipped() / SKIP_SLICE_LINEAR_WIDTH;
  executor.submit(() -> {
    int slice=firstSlice;
    for (    int tohave : SKIP_SLICES_HEIGHTS) {
      int sliceSkips=slice * SKIP_SLICE_LINEAR_WIDTH - SKIP_SLICE_LINEAR_DELTA;
      DBCursorPoolEntryKey sliceKey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getFilter(),sliceSkips,-1);
      long existing=getSliceHeight(sliceKey);
      for (long cont=tohave - existing; cont > 0; cont--) {
        DBCursor cursor=dbsDAO.getCollectionDBCursor(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys());
        cursor.skip(sliceSkips);
        DBCursorPoolEntryKey newkey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,System.nanoTime());
        cache.put(newkey,cursor);
        LOGGER.debug("String_Node_Str",newkey);
      }
      slice++;
    }
  }
);
}

Fixed version (ground truth):
private void populateCacheLinear(DBCursorPoolEntryKey key){
  if (key.getSkipped() < SKIP_SLICE_LINEAR_WIDTH) {
    return;
  }
  int firstSlice=key.getSkipped() / SKIP_SLICE_LINEAR_WIDTH;
  executor.submit(() -> {
    int slice=firstSlice;
    for (    int tohave : SKIP_SLICES_HEIGHTS) {
      int sliceSkips=slice * SKIP_SLICE_LINEAR_WIDTH - SKIP_SLICE_LINEAR_DELTA;
      DBCursorPoolEntryKey sliceKey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getFilter(),sliceSkips,-1);
      long existing=getSliceHeight(sliceKey);
      long tocreate=tohave - existing;
      if (tocreate > 0) {
        DBCursor cursor=dbsDAO.getCollectionDBCursor(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys());
        cursor.limit(1000 + SKIP_SLICE_LINEAR_DELTA).skip(sliceSkips);
        cursor.hasNext();
        DBCursorPoolEntryKey newkey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,System.nanoTime());
        cache.put(newkey,cursor);
        LOGGER.debug("String_Node_Str",newkey);
        tocreate--;
        for (long cont=tocreate; cont > 0; cont--) {
          newkey=new DBCursorPoolEntryKey(key.getCollection(),key.getSort(),key.getFilter(),key.getKeys(),sliceSkips,System.nanoTime());
          cache.put(newkey,cursor.copy());
          LOGGER.debug("String_Node_Str",newkey);
        }
      }
      slice++;
    }
  }
);
}
Program: 93500
Project: 93500
Buggy source:
private void populateCache(DBCursorPoolEntryKey key,EAGER_CURSOR_ALLOCATION_POLICY allocationPolicy){
  if (allocationPolicy == EAGER_CURSOR_ALLOCATION_POLICY.LINEAR) {
    populateCacheLinear(key);
  }
 else   if (allocationPolicy == EAGER_CURSOR_ALLOCATION_POLICY.RANDOM) {
    populateCacheRandom(key);
  }
}

Fixed version (ground truth):
void populateCache(DBCursorPoolEntryKey key,EAGER_CURSOR_ALLOCATION_POLICY allocationPolicy){
  if (allocationPolicy == EAGER_CURSOR_ALLOCATION_POLICY.LINEAR) {
    populateCacheLinear(key);
  }
 else   if (allocationPolicy == EAGER_CURSOR_ALLOCATION_POLICY.RANDOM) {
    populateCacheRandom(key);
  }
}
Program: 93501
Project: 93501
Buggy source:
private DBCursorPool(DbsDAO dbsDAO){
  this.dbsDAO=dbsDAO;
  cache=CacheFactory.createLocalCache(POOL_SIZE,Cache.EXPIRE_POLICY.AFTER_READ,TTL,(  Map.Entry<DBCursorPoolEntryKey,Optional<DBCursor>> entry) -> {
    if (entry != null && entry.getValue() != null) {
      entry.getValue().ifPresent(v -> v.close());
    }
  }
);
  collSizes=CacheFactory.createLocalLoadingCache(100,org.restheart.cache.Cache.EXPIRE_POLICY.AFTER_WRITE,60 * 1000,(  DBCursorPoolEntryKey key) -> {
    return dbsDAO.getCollectionSize(key.getCollection(),key.getFilter());
  }
);
  if (LOGGER.isDebugEnabled()) {
    Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> {
      getCacheSizes().forEach((s,c) -> {
        LOGGER.debug("String_Node_Str",s,c);
      }
);
      LOGGER.trace("String_Node_Str",cache.asMap().keySet());
    }
,1,1,TimeUnit.MINUTES);
  }
}

Fixed version (ground truth):
private DBCursorPool(DbsDAO dbsDAO){
  this.dbsDAO=dbsDAO;
  cache=CacheFactory.createLocalCache(POOL_SIZE,Cache.EXPIRE_POLICY.AFTER_READ,TTL);
  collSizes=CacheFactory.createLocalLoadingCache(100,org.restheart.cache.Cache.EXPIRE_POLICY.AFTER_WRITE,60 * 1000,(  DBCursorPoolEntryKey key) -> {
    return dbsDAO.getCollectionSize(key.getCollection(),key.getFilter());
  }
);
  if (LOGGER.isDebugEnabled()) {
    Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(() -> {
      getCacheSizes().forEach((s,c) -> {
        LOGGER.debug("String_Node_Str",s,c);
      }
);
      LOGGER.trace("String_Node_Str",cache.asMap().keySet());
    }
,1,1,TimeUnit.MINUTES);
  }
}
Program: 93502
Project: 93502
Buggy source:
public void getPagesLinearly() throws Exception {
  Integer _page=threadPages.get(Thread.currentThread().getId());
  if (_page == null) {
    threadPages.put(Thread.currentThread().getId(),page);
    _page=page;
  }
  String pagedUrl=url + "String_Node_Str" + (_page % 10000);
  _page++;
  threadPages.put(Thread.currentThread().getId(),_page);
  if (printData) {
    System.out.println(Thread.currentThread().getId() + "String_Node_Str" + pagedUrl);
  }
  Response resp=httpExecutor.execute(Request.Get(new URI(pagedUrl)));
  HttpResponse httpResp=resp.returnResponse();
  assertNotNull(httpResp);
  HttpEntity entity=httpResp.getEntity();
  assertNotNull(entity);
  StatusLine statusLine=httpResp.getStatusLine();
  assertNotNull(statusLine);
  assertEquals("String_Node_Str",HttpStatus.SC_OK,statusLine.getStatusCode());
}

Fixed version (ground truth):
public void getPagesLinearly() throws Exception {
  Integer _page=threadPages.get(Thread.currentThread().getId());
  if (_page == null) {
    threadPages.put(Thread.currentThread().getId(),page);
    _page=page;
  }
  String pagedUrl=url + "String_Node_Str" + (_page % 10000);
  if (getEager() != null) {
    pagedUrl=pagedUrl + "String_Node_Str" + getEager();
  }
  _page++;
  threadPages.put(Thread.currentThread().getId(),_page);
  if (printData) {
    System.out.println(Thread.currentThread().getId() + "String_Node_Str" + pagedUrl);
  }
  Response resp=httpExecutor.execute(Request.Get(new URI(pagedUrl)));
  HttpResponse httpResp=resp.returnResponse();
  assertNotNull(httpResp);
  HttpEntity entity=httpResp.getEntity();
  assertNotNull(entity);
  StatusLine statusLine=httpResp.getStatusLine();
  assertNotNull(statusLine);
  assertEquals("String_Node_Str",HttpStatus.SC_OK,statusLine.getStatusCode());
}
Program: 93503
Project: 93503
Buggy source:
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithDocId(RequestContext context,String dbName,String collName,Object id) throws UnsupportedDocumentIdException {
  DOC_ID_TYPE docIdType=URLUtils.checkId(id);
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append(id);
  if (docIdType == DOC_ID_TYPE.STRING_OID && ObjectId.isValid((String)id)) {
    sb.append("String_Node_Str");
  }
 else   if (docIdType != DOC_ID_TYPE.STRING_OID) {
    sb.append("String_Node_Str").append(docIdType.name());
  }
  return context.mapUri(sb.toString().replaceAll("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithDocId(RequestContext context,String dbName,String collName,Object id) throws UnsupportedDocumentIdException {
  DOC_ID_TYPE docIdType=URLUtils.checkId(id);
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append(id);
  if (docIdType == DOC_ID_TYPE.STRING_OID && ObjectId.isValid((String)id)) {
    sb.append("String_Node_Str");
  }
 else   if (docIdType != DOC_ID_TYPE.STRING_OID) {
    sb.append("String_Node_Str").append(docIdType.name());
  }
  return context.mapUri(sb.toString());
}
Program: 93504
Project: 93504
Buggy source:
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param referenceField
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithFilterOne(RequestContext context,String dbName,String collName,String referenceField,Object id) throws UnsupportedDocumentIdException {
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(referenceField).append("String_Node_Str").append("String_Node_Str").append(getIdString(id)).append("String_Node_Str");
  return context.mapUri(sb.toString().replaceAll("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param referenceField
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithFilterOne(RequestContext context,String dbName,String collName,String referenceField,Object id) throws UnsupportedDocumentIdException {
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append("String_Node_Str").append("String_Node_Str").append(referenceField).append("String_Node_Str").append("String_Node_Str").append(getIdString(id)).append("String_Node_Str");
  return context.mapUri(sb.toString());
}
Program: 93505
Project: 93505
Buggy source:
private static String getIdsString(Object[] ids) throws UnsupportedDocumentIdException {
  if (ids == null) {
    return null;
  }
  int cont=0;
  String[] _ids=new String[ids.length];
  for (  Object id : ids) {
    _ids[cont]=getIdString(id);
    cont++;
  }
  return Arrays.toString(_ids);
}

Fixed version (ground truth):
private static String getIdsString(Object[] ids) throws UnsupportedDocumentIdException {
  if (ids == null) {
    return null;
  }
  int cont=0;
  String[] _ids=new String[ids.length];
  for (  Object id : ids) {
    _ids[cont]=getIdString(id);
    cont++;
  }
  return JsonUtils.minify(Arrays.toString(_ids));
}
Program: 93506
Project: 93506
Buggy source:
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param referenceField
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithFilterManyInverse(RequestContext context,String dbName,String collName,String referenceField,Object id) throws UnsupportedDocumentIdException {
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append("String_Node_Str").append(referenceField).append("String_Node_Str").append("String_Node_Str").append(getIdString(id)).append("String_Node_Str");
  return context.mapUri(sb.toString().replaceAll("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * @param context
 * @param dbName
 * @param collName
 * @param referenceField
 * @param id
 * @return
 * @throws org.restheart.hal.UnsupportedDocumentIdException
 */
static public String getUriWithFilterManyInverse(RequestContext context,String dbName,String collName,String referenceField,Object id) throws UnsupportedDocumentIdException {
  StringBuilder sb=new StringBuilder();
  sb.append("String_Node_Str").append(dbName).append("String_Node_Str").append(collName).append("String_Node_Str").append("String_Node_Str").append(referenceField).append("String_Node_Str").append("String_Node_Str").append(getIdString(id)).append("String_Node_Str");
  return JsonUtils.minify(context.mapUri(sb.toString()));
}