nus-yam/ex-repair huggingface dataset:
Program: 168432
Project: 168432
Buggy source:
@Test public void testNonExistingEndPoints() throws IOException {
  HttpURLConnection urlConn=request("String_Node_Str",HttpMethod.POST);
  writeContent(urlConn,"String_Node_Str");
  Assert.assertEquals(404,urlConn.getResponseCode());
  urlConn.disconnect();
}

Fixed version (ground truth):
@Test public void testNonExistingEndPoints() throws IOException {
  HttpURLConnection urlConn=request("String_Node_Str",HttpMethod.POST);
  writeContent(urlConn,"String_Node_Str");
  Assert.assertEquals(404,urlConn.getResponseCode());
  urlConn.disconnect();
  urlConn=request("String_Node_Str",HttpMethod.GET,true);
  Assert.assertEquals(200,urlConn.getResponseCode());
  urlConn.getInputStream().close();
  urlConn.disconnect();
  urlConn=request("String_Node_Str",HttpMethod.GET);
  Assert.assertEquals(404,urlConn.getResponseCode());
}
Program: 168433
Project: 168433
Buggy source:
/** 
 * Add a source and destination.
 * @param source  Source path to be routed. Routed path can have named wild-card pattern with braces "{}".
 * @param destination Destination of the path.
 */
public void add(final String source,final T destination){
  String path=source.replaceAll("String_Node_Str","String_Node_Str");
  path=(path.endsWith("String_Node_Str") && path.length() > 1) ? path.substring(0,path.length() - 1) : path;
  String[] parts=path.split("String_Node_Str");
  if (parts.length - 1 > maxPathParts) {
    throw new IllegalArgumentException(String.format("String_Node_Str",source,maxPathParts));
  }
  StringBuilder sb=new StringBuilder();
  List<String> groupNames=Lists.newArrayList();
  for (  String part : parts) {
    Matcher groupMatcher=GROUP_PATTERN.matcher(part);
    if (groupMatcher.matches()) {
      groupNames.add(groupMatcher.group(1));
      sb.append("String_Node_Str");
    }
 else     if (WILD_CARD_PATTERN.matcher(part).matches()) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append(part);
    }
    sb.append("String_Node_Str");
  }
  sb.setLength(sb.length() - 1);
  Pattern pattern=Pattern.compile(sb.toString());
  patternRouteList.add(ImmutablePair.of(pattern,new RouteDestinationWithGroups(destination,groupNames)));
}

Fixed version (ground truth):
/** 
 * Add a source and destination.
 * @param source  Source path to be routed. Routed path can have named wild-card pattern with braces "{}".
 * @param destination Destination of the path.
 */
public void add(final String source,final T destination){
  String path=source.replaceAll("String_Node_Str","String_Node_Str");
  path=(path.endsWith("String_Node_Str") && path.length() > 1) ? path.substring(0,path.length() - 1) : path;
  String[] parts=path.split("String_Node_Str",maxPathParts + 2);
  if (parts.length - 1 > maxPathParts) {
    throw new IllegalArgumentException(String.format("String_Node_Str",source,maxPathParts));
  }
  StringBuilder sb=new StringBuilder();
  List<String> groupNames=Lists.newArrayList();
  for (  String part : parts) {
    Matcher groupMatcher=GROUP_PATTERN.matcher(part);
    if (groupMatcher.matches()) {
      groupNames.add(groupMatcher.group(1));
      sb.append("String_Node_Str");
    }
 else     if (WILD_CARD_PATTERN.matcher(part).matches()) {
      sb.append("String_Node_Str");
    }
 else {
      sb.append(part);
    }
    sb.append("String_Node_Str");
  }
  sb.setLength(sb.length() - 1);
  Pattern pattern=Pattern.compile(sb.toString());
  patternRouteList.add(ImmutablePair.of(pattern,new RouteDestinationWithGroups(destination,groupNames)));
}
Program: 168435
Project: 168435
Buggy source:
@Override protected void shutDown() throws Exception {
  LOG.info("String_Node_Str",serviceName,bindAddress);
  try {
    bootstrap.shutdown();
    if (!channelGroup.close().await(CLOSE_CHANNEL_TIMEOUT,TimeUnit.SECONDS)) {
      LOG.warn("String_Node_Str");
    }
  }
  finally {
    resourceHandler.destroy(handlerContext);
    bootstrap.releaseExternalResources();
    if (executionHandler != null) {
      executionHandler.releaseExternalResources();
      ExecutorUtil.terminate(executionHandler.getExecutor());
    }
  }
  LOG.info("String_Node_Str",serviceName,bindAddress);
}

Fixed version (ground truth):
@Override protected void shutDown() throws Exception {
  LOG.info("String_Node_Str",serviceName);
  try {
    bootstrap.shutdown();
    if (!channelGroup.close().await(CLOSE_CHANNEL_TIMEOUT,TimeUnit.SECONDS)) {
      LOG.warn("String_Node_Str");
    }
  }
  finally {
    resourceHandler.destroy(handlerContext);
    bootstrap.releaseExternalResources();
    if (executionHandler != null) {
      executionHandler.releaseExternalResources();
      ExecutorUtil.terminate(executionHandler.getExecutor());
    }
  }
  LOG.debug("String_Node_Str",serviceName,bindAddress);
}
Program: 168436
Project: 168436
Buggy source:
@Override protected void startUp() throws Exception {
  LOG.info("String_Node_Str",serviceName,bindAddress);
  bootStrap(execThreadPoolSize,execThreadKeepAliveSecs);
  Channel channel=bootstrap.bind(bindAddress);
  channelGroup.add(channel);
  bindAddress=((InetSocketAddress)channel.getLocalAddress());
  LOG.info("String_Node_Str",serviceName,bindAddress);
}

Fixed version (ground truth):
@Override protected void startUp() throws Exception {
  LOG.info("String_Node_Str",serviceName,bindAddress);
  bootStrap(execThreadPoolSize,execThreadKeepAliveSecs);
  Channel channel=bootstrap.bind(bindAddress);
  channelGroup.add(channel);
  bindAddress=((InetSocketAddress)channel.getLocalAddress());
  LOG.debug("String_Node_Str",serviceName,bindAddress);
}
Program: 168437
Project: 168437
Buggy source:
public SSLHandlerFactory(SSLConfig sslConfig){
  if (sslConfig.getKeyStore() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (sslConfig.getKeyStorePassword() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String algorithm=Security.getProperty("String_Node_Str");
  if (algorithm == null) {
    algorithm="String_Node_Str";
  }
  try {
    KeyStore ks=getKeyStore(sslConfig.getKeyStore(),sslConfig.getKeyStorePassword());
    KeyManagerFactory kmf=KeyManagerFactory.getInstance(algorithm);
    kmf.init(ks,(sslConfig.getCertificatePassword() != null) ? sslConfig.getCertificatePassword().toCharArray() : sslConfig.getKeyStorePassword().toCharArray());
    TrustManagerFactory tmf=null;
    if (sslConfig.getTrustKeyStore() != null) {
      if (sslConfig.getTrustKeyStorePassword() == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      this.needClientAuth=true;
      KeyStore tks=getKeyStore(sslConfig.getTrustKeyStore(),sslConfig.getTrustKeyStorePassword());
      tmf=TrustManagerFactory.getInstance(algorithm);
      tmf.init(tks);
    }
    serverContext=SSLContext.getInstance(protocol);
    serverContext.init(kmf.getKeyManagers(),tmf != null ? tmf.getTrustManagers() : null,null);
  }
 catch (  Exception e) {
    throw new IllegalArgumentException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
public SSLHandlerFactory(SSLConfig sslConfig){
  if (sslConfig.getKeyStore() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (sslConfig.getKeyStorePassword() == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  String algorithm=Security.getProperty("String_Node_Str");
  if (algorithm == null) {
    algorithm="String_Node_Str";
  }
  try {
    KeyStore ks=getKeyStore(sslConfig.getKeyStore(),sslConfig.getKeyStorePassword());
    KeyManagerFactory kmf=KeyManagerFactory.getInstance(algorithm);
    kmf.init(ks,sslConfig.getCertificatePassword() != null ? sslConfig.getCertificatePassword().toCharArray() : sslConfig.getKeyStorePassword().toCharArray());
    TrustManagerFactory tmf=null;
    if (sslConfig.getTrustKeyStore() != null) {
      if (sslConfig.getTrustKeyStorePassword() == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      this.needClientAuth=true;
      KeyStore tks=getKeyStore(sslConfig.getTrustKeyStore(),sslConfig.getTrustKeyStorePassword());
      tmf=TrustManagerFactory.getInstance(algorithm);
      tmf.init(tks);
    }
    serverContext=SSLContext.getInstance(protocol);
    serverContext.init(kmf.getKeyManagers(),tmf != null ? tmf.getTrustManagers() : null,null);
  }
 catch (  Exception e) {
    throw new IllegalArgumentException("String_Node_Str",e);
  }
}
Program: 168438
Project: 168438
Buggy source:
private static KeyStore getKeyStore(File keyStore,String keyStorePassword) throws Exception {
  KeyStore ks=KeyStore.getInstance("String_Node_Str");
  InputStream inputStream=new FileInputStream(keyStore);
  try {
    ks.load(inputStream,keyStorePassword.toCharArray());
  }
  finally {
    inputStream.close();
  }
  return ks;
}

Fixed version (ground truth):
private static KeyStore getKeyStore(File keyStore,String keyStorePassword) throws KeyStoreLoadException {
  InputStream inputStream=null;
  KeyStore ks=null;
  try {
    ks=KeyStore.getInstance("String_Node_Str");
    inputStream=new FileInputStream(keyStore);
    ks.load(inputStream,keyStorePassword.toCharArray());
  }
 catch (  FileNotFoundException e) {
    throw new KeyStoreLoadException(e);
  }
catch (  CertificateException e) {
    throw new KeyStoreLoadException(e);
  }
catch (  NoSuchAlgorithmException e) {
    throw new KeyStoreLoadException(e);
  }
catch (  KeyStoreException e) {
    throw new KeyStoreLoadException(e);
  }
catch (  IOException e) {
    throw new KeyStoreLoadException(e);
  }
 finally {
    if (inputStream != null) {
      try {
        inputStream.close();
      }
 catch (      IOException e) {
        LOG.error("String_Node_Str",e);
      }
    }
  }
  return ks;
}
Program: 168441
Project: 168441
Buggy source:
/** 
 * Cast the value according to column type.
 * @param value the value casted
 * @param columnType the column type
 */
private static Object castValue(Object value,ColumnType columnType){
  Object castedValue=value;
switch (columnType.getDataType()) {
case FLOAT:
    castedValue=((Double)value).floatValue();
  break;
case SET:
case LIST:
case MAP:
break;
default :
break;
}
return castedValue;
}

Fixed version (ground truth):
/** 
 * Cast the value according to column type.
 * @param value the value casted
 * @param columnType the column type
 */
private static Object castValue(Object value,ColumnType columnType){
  if (value == null)   return value;
  Object castedValue=value;
switch (columnType.getDataType()) {
case FLOAT:
    castedValue=((Double)value).floatValue();
  break;
case NATIVE:
castedValue=value.toString();
break;
case SET:
case LIST:
case MAP:
break;
default :
break;
}
return castedValue;
}
Program: 168442
Project: 168442
Buggy source:
/** 
 * Instantiates a new logical workflow executor ready for the execution.
 * @param logicalWorkflowParsed the logical workflow parsed.
 * @throws MongoValidationException if the query specified in the logical workflow is not supported.
 * @throws ExecutionException if the execution fails.
 * @throws UnsupportedException if the specified operation is not supported.
 */
public LogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws MongoValidationException, ExecutionException, UnsupportedException {
  logicalWorkflowData=logicalWorkflowParsed;
  this.buildQuery();
}

Fixed version (ground truth):
/** 
 * Instantiates a new logical workflow executor ready for the execution.
 * @param logicalWorkflowParsed the logical workflow parsed.
 * @throws ExecutionException if the execution fails or the query specified in the logical workflow is not supported.
 * @throws UnsupportedException if the specified operation is not supported.
 */
public LogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws ExecutionException, UnsupportedException {
  logicalWorkflowData=logicalWorkflowParsed;
  this.buildQuery();
}
Program: 168443
Project: 168443
Buggy source:
@Override public void run(){
  try {
    shutdown();
  }
 catch (  ExecutionException e) {
    logger.error("String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    shutdown();
  }
 catch (  ExecutionException e) {
    logger.error("String_Node_Str" + e.getMessage(),e);
  }
}
Program: 168444
Project: 168444
Buggy source:
/** 
 * Attach shut down hook.
 */
public void attachShutDownHook(){
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      try {
        shutdown();
      }
 catch (      ExecutionException e) {
        logger.error("String_Node_Str");
      }
    }
  }
);
}

Fixed version (ground truth):
/** 
 * Attach shut down hook.
 */
public void attachShutDownHook(){
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      try {
        shutdown();
      }
 catch (      ExecutionException e) {
        logger.error("String_Node_Str" + e.getMessage(),e);
      }
    }
  }
);
}
Program: 168445
Project: 168445
Buggy source:
@Override public boolean isConnected(){
  boolean isConnected=false;
  if (mongoClient != null) {
    try {
      mongoClient.getConnectPoint();
      isConnected=true;
    }
 catch (    Exception error) {
      logger.error(error.getMessage());
    }
  }
  return isConnected;
}

Fixed version (ground truth):
@Override public final boolean isConnected(){
  boolean isConnected=false;
  if (mongoClient != null) {
    try {
      mongoClient.getConnectPoint();
      isConnected=true;
    }
 catch (    Exception error) {
      logger.error("String_Node_Str" + error.getMessage(),error);
    }
  }
  return isConnected;
}
Program: 168446
Project: 168446
Buggy source:
/** 
 * Create a collection in MongoDB.
 * @param tableMetadata the tableMetadata
 * @param connection the connection which contains the native connector
 * @throws MongoValidationException if the specified operation is not supported
 * @throws ExecutionException if an error exist when running the database command
 */
@Override protected void createTable(TableMetadata tableMetadata,Connection<MongoClient> connection) throws MongoValidationException, ExecutionException {
  if (tableMetadata == null) {
    throw new MongoValidationException("String_Node_Str");
  }
  if (tableMetadata.getName() == null) {
    throw new MongoValidationException("String_Node_Str");
  }
  if (ShardUtils.isCollectionSharded(SelectorOptionsUtils.processOptions(tableMetadata.getOptions()))) {
    ShardUtils.shardCollection((MongoClient)connection.getNativeConnection(),tableMetadata);
  }
}

Fixed version (ground truth):
/** 
 * Create a collection in MongoDB.
 * @param tableMetadata the tableMetadata
 * @param connection the connection which contains the native connector
 * @throws ExecutionException if an error exist when running the database command or the specified operation is not supported
 */
@Override protected void createTable(TableMetadata tableMetadata,Connection<MongoClient> connection) throws ExecutionException {
  if (tableMetadata == null) {
    throw new MongoValidationException("String_Node_Str");
  }
  if (tableMetadata.getName() == null) {
    throw new MongoValidationException("String_Node_Str");
  }
  if (ShardUtils.isCollectionSharded(SelectorOptionsUtils.processOptions(tableMetadata.getOptions()))) {
    ShardUtils.shardCollection((MongoClient)connection.getNativeConnection(),tableMetadata);
  }
}
Program: 168447
Project: 168447
Buggy source:
/** 
 * Create an index.
 * @param indexMetadata the index metadata
 * @param connection the connection
 * @throws MongoValidationException if the specified index is not supported
 * @throws ExecutionException if an error exist when running the database command
 */
@Override protected void createIndex(IndexMetadata indexMetadata,Connection<MongoClient> connection) throws MongoValidationException, ExecutionException {
  DB db=connection.getNativeConnection().getDB(indexMetadata.getName().getTableName().getCatalogName().getName());
  DBObject indexDBObject=IndexUtils.getIndexDBObject(indexMetadata);
  DBObject indexOptionsDBObject=IndexUtils.getCustomOptions(indexMetadata);
  try {
    db.getCollection(indexMetadata.getName().getTableName().getName()).createIndex(indexDBObject,indexOptionsDBObject);
  }
 catch (  MongoException e) {
    logger.error("String_Node_Str" + e.getMessage());
    throw new ExecutionException(e.getMessage(),e);
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + indexDBObject.toString() + "String_Node_Str"+ indexOptionsDBObject);
  }
}

Fixed version (ground truth):
/** 
 * Create an index.
 * @param indexMetadata the index metadata
 * @param connection the connection
 * @throws ExecutionException if an error exist when running the database command or the specified operation is not supported
 */
@Override protected void createIndex(IndexMetadata indexMetadata,Connection<MongoClient> connection) throws ExecutionException {
  DB db=connection.getNativeConnection().getDB(indexMetadata.getName().getTableName().getCatalogName().getName());
  DBObject indexDBObject=IndexUtils.getIndexDBObject(indexMetadata);
  DBObject indexOptionsDBObject=IndexUtils.getCustomOptions(indexMetadata);
  try {
    db.getCollection(indexMetadata.getName().getTableName().getName()).createIndex(indexDBObject,indexOptionsDBObject);
  }
 catch (  MongoException e) {
    logger.error("String_Node_Str" + e.getMessage());
    throw new ExecutionException(e.getMessage(),e);
  }
  if (logger.isDebugEnabled()) {
    logger.debug("String_Node_Str" + indexDBObject.toString() + "String_Node_Str"+ indexOptionsDBObject);
  }
}
Program: 168448
Project: 168448
Buggy source:
@Override protected void alterTable(TableName tableName,AlterOptions alterOptions,Connection<MongoClient> connection) throws MongoValidationException, ExecutionException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  DBCollection collection=db.getCollection(tableName.getName());
switch (alterOptions.getOption()) {
case ADD_COLUMN:
    break;
case ALTER_COLUMN:
  throw new MongoValidationException("String_Node_Str");
case DROP_COLUMN:
String name=alterOptions.getColumnMetadata().getName().getName();
collection.updateMulti(new BasicDBObject(),AlterOptionsUtils.buildDropColumnDBObject(name));
break;
case ALTER_OPTIONS:
default :
throw new MongoValidationException("String_Node_Str");
}
}

Fixed version (ground truth):
@Override protected void alterTable(TableName tableName,AlterOptions alterOptions,Connection<MongoClient> connection) throws ExecutionException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  DBCollection collection=db.getCollection(tableName.getName());
switch (alterOptions.getOption()) {
case ADD_COLUMN:
    break;
case ALTER_COLUMN:
  throw new MongoValidationException("String_Node_Str");
case DROP_COLUMN:
String name=alterOptions.getColumnMetadata().getName().getName();
collection.updateMulti(new BasicDBObject(),AlterOptionsUtils.buildDropColumnDBObject(name));
break;
case ALTER_OPTIONS:
default :
throw new MongoValidationException("String_Node_Str");
}
}
Program: 168449
Project: 168449
Buggy source:
/** 
 * Drop an index.
 * @param indexMetadata the index metadata
 * @param connection the connection
 * @throws ExecutionException if an error exist when running the database command
 * @throws MongoValidationException if the specified operation is not supported
 */
@Override protected void dropIndex(IndexMetadata indexMetadata,Connection<MongoClient> connection) throws ExecutionException, MongoValidationException {
  DB db=connection.getNativeConnection().getDB(indexMetadata.getName().getTableName().getCatalogName().getName());
  String indexName=null;
  if (indexMetadata.getName() != null) {
    indexName=indexMetadata.getName().getName();
  }
  if (indexName != null) {
    try {
      db.getCollection(indexMetadata.getName().getTableName().getName()).dropIndex(indexName);
    }
 catch (    MongoException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new ExecutionException(e.getMessage(),e);
    }
  }
 else {
    IndexUtils.dropIndexWithDefaultName(indexMetadata,db);
  }
}

Fixed version (ground truth):
/** 
 * Drop an index.
 * @param indexMetadata the index metadata
 * @param connection the connection
 * @throws ExecutionException if an error exist when running the database command or the specified operation is not supported
 */
@Override protected void dropIndex(IndexMetadata indexMetadata,Connection<MongoClient> connection) throws ExecutionException {
  DB db=connection.getNativeConnection().getDB(indexMetadata.getName().getTableName().getCatalogName().getName());
  String indexName=null;
  if (indexMetadata.getName() != null) {
    indexName=indexMetadata.getName().getName();
  }
  if (indexName != null) {
    try {
      db.getCollection(indexMetadata.getName().getTableName().getName()).dropIndex(indexName);
    }
 catch (    MongoException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new ExecutionException(e.getMessage(),e);
    }
  }
 else {
    IndexUtils.dropIndexWithDefaultName(indexMetadata,db);
  }
}
Program: 168450
Project: 168450
Buggy source:
@Override protected void update(TableName tableName,Collection<Relation> assignments,Collection<Filter> whereClauses,Connection<MongoClient> connection) throws MongoValidationException, ExecutionException, UnsupportedException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  DBCollection coll=db.getCollection(tableName.getName());
  UpdateDBObjectBuilder updateBuilder=new UpdateDBObjectBuilder();
  for (  Relation rel : assignments) {
    updateBuilder.addUpdateRelation(rel.getLeftTerm(),rel.getOperator(),rel.getRightTerm());
  }
  try {
    coll.update(buildFilter(whereClauses),updateBuilder.build(),false,true);
  }
 catch (  MongoException e) {
    logger.error("String_Node_Str" + e.getMessage());
    throw new ExecutionException(e.getMessage(),e);
  }
}

Fixed version (ground truth):
@Override protected void update(TableName tableName,Collection<Relation> assignments,Collection<Filter> whereClauses,Connection<MongoClient> connection) throws ExecutionException, UnsupportedException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  DBCollection coll=db.getCollection(tableName.getName());
  UpdateDBObjectBuilder updateBuilder=new UpdateDBObjectBuilder();
  for (  Relation rel : assignments) {
    updateBuilder.addUpdateRelation(rel.getLeftTerm(),rel.getOperator(),rel.getRightTerm());
  }
  try {
    coll.update(buildFilter(whereClauses),updateBuilder.build(),false,true);
  }
 catch (  MongoException e) {
    logger.error("String_Node_Str" + e.getMessage());
    throw new ExecutionException(e.getMessage(),e);
  }
}
Program: 168451
Project: 168451
Buggy source:
@Override protected void delete(TableName tableName,Collection<Filter> whereClauses,Connection<MongoClient> connection) throws MongoValidationException, ExecutionException, UnsupportedException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  if (db.collectionExists(tableName.getName())) {
    DBCollection coll=db.getCollection(tableName.getName());
    try {
      coll.remove(buildFilter(whereClauses));
    }
 catch (    MongoException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new MongoDeleteException(e.getMessage(),e);
    }
  }
}

Fixed version (ground truth):
@Override protected void delete(TableName tableName,Collection<Filter> whereClauses,Connection<MongoClient> connection) throws ExecutionException, UnsupportedException {
  DB db=connection.getNativeConnection().getDB(tableName.getCatalogName().getName());
  if (db.collectionExists(tableName.getName())) {
    DBCollection coll=db.getCollection(tableName.getName());
    try {
      coll.remove(buildFilter(whereClauses));
    }
 catch (    MongoException e) {
      logger.error("String_Node_Str" + e.getMessage());
      throw new MongoDeleteException(e.getMessage(),e);
    }
  }
}
Program: 168452
Project: 168452
Buggy source:
public static List<IndexMetadata> discoverIndexes(DBCollection collection){
  List<DBObject> indexInfo=collection.getIndexInfo();
  String db=collection.getDB().getName();
  String collName=collection.getName();
  List<IndexMetadata> indexMetadataList=new ArrayList<>(indexInfo.size());
  for (  DBObject dbObject : indexInfo) {
    BasicDBObject key=(BasicDBObject)dbObject.get("String_Node_Str");
    IndexMetadataBuilder indexMetadataBuilder=new IndexMetadataBuilder(db,collName,(String)dbObject.get("String_Node_Str"),getIndexType(key));
    for (    String field : key.keySet()) {
      indexMetadataBuilder.addColumn(field,null);
    }
    indexMetadataList.add(indexMetadataBuilder.build());
  }
  return indexMetadataList;
}

Fixed version (ground truth):
/** 
 * Discover the existing indexes stored in the collection.
 * @param collection the collection
 * @return the list of indexMetadata.
 */
public static List<IndexMetadata> discoverIndexes(DBCollection collection){
  List<DBObject> indexInfo=collection.getIndexInfo();
  String db=collection.getDB().getName();
  String collName=collection.getName();
  List<IndexMetadata> indexMetadataList=new ArrayList<>(indexInfo.size());
  for (  DBObject dbObject : indexInfo) {
    BasicDBObject key=(BasicDBObject)dbObject.get("String_Node_Str");
    IndexMetadataBuilder indexMetadataBuilder=new IndexMetadataBuilder(db,collName,(String)dbObject.get("String_Node_Str"),getIndexType(key));
    for (    String field : key.keySet()) {
      indexMetadataBuilder.addColumn(field,null);
    }
    indexMetadataList.add(indexMetadataBuilder.build());
  }
  return indexMetadataList;
}
Program: 168453
Project: 168453
Buggy source:
/** 
 * Gets the index type.
 * @param key the key
 * @return DEFAULT when involved fields have ascending index. CUSTOM otherwise
 */
private static IndexType getIndexType(BasicDBObject key){
  boolean isDefault=true;
  IndexType indexType;
  Iterator<Object> iterator=key.values().iterator();
  while (iterator.hasNext() && isDefault == true) {
    isDefault=iterator.next().toString().startsWith("String_Node_Str");
  }
  if (isDefault) {
    indexType=IndexType.DEFAULT;
  }
 else {
    indexType=IndexType.CUSTOM;
  }
  return indexType;
}

Fixed version (ground truth):
/** 
 * Gets the index type.
 * @param key the key
 * @return DEFAULT when involved fields have ascending index. CUSTOM otherwise
 */
private static IndexType getIndexType(BasicDBObject key){
  boolean isDefault=true;
  IndexType indexType;
  Iterator<Object> iterator=key.values().iterator();
  while (iterator.hasNext() && isDefault) {
    isDefault=iterator.next().toString().startsWith("String_Node_Str");
  }
  if (isDefault) {
    indexType=IndexType.DEFAULT;
  }
 else {
    indexType=IndexType.CUSTOM;
  }
  return indexType;
}
Program: 168454
Project: 168454
Buggy source:
public static List<String> discoverField(DBCollection collection){
  String map="String_Node_Str";
  String reduce="String_Node_Str";
  MapReduceCommand mapReduceCommand=new MapReduceCommand(collection,map,reduce,null,OutputType.INLINE,null);
  DBObject getFieldsCommand=mapReduceCommand.toDBObject();
  CommandResult command=collection.getDB().command(getFieldsCommand);
  BasicDBList results=(BasicDBList)command.get("String_Node_Str");
  Set<String> fields=new HashSet<>();
  if (results != null) {
    for (    Object object : results) {
      DBObject bson=(DBObject)object;
      fields.add((String)bson.get("String_Node_Str"));
    }
  }
  return new ArrayList<String>(fields);
}

Fixed version (ground truth):
/** 
 * Discover the existing fields stored in the collection.
 * @param collection the collection
 * @return the list of fields including the _id
 */
public static List<String> discoverField(DBCollection collection){
  String map="String_Node_Str";
  String reduce="String_Node_Str";
  MapReduceCommand mapReduceCommand=new MapReduceCommand(collection,map,reduce,null,OutputType.INLINE,null);
  DBObject getFieldsCommand=mapReduceCommand.toDBObject();
  CommandResult command=collection.getDB().command(getFieldsCommand);
  BasicDBList results=(BasicDBList)command.get("String_Node_Str");
  Set<String> fields=new HashSet<>();
  if (results != null) {
    for (    Object object : results) {
      DBObject bson=(DBObject)object;
      fields.add((String)bson.get("String_Node_Str"));
    }
  }
  return new ArrayList<String>(fields);
}
Program: 168457
Project: 168457
Buggy source:
/** 
 * Creates the Mongo index based on the index metadata options.
 * @param indexMetadata the index metadata
 * @return the Mongo index
 * @throws MongoValidationException the unsupported exception
 */
public static DBObject getIndexDBObject(IndexMetadata indexMetadata) throws MongoValidationException {
  IndexType indexType=indexMetadata.getType();
  DBObject indexDBObject=new BasicDBObject();
  if (indexType == IndexType.DEFAULT) {
    for (    ColumnMetadata columnMeta : indexMetadata.getColumns().values()) {
      indexDBObject.put(columnMeta.getName().getName(),1);
    }
  }
 else   if (indexType == IndexType.FULL_TEXT) {
    for (    ColumnMetadata columnMeta : indexMetadata.getColumns().values()) {
      indexDBObject.put(columnMeta.getName().getName(),"String_Node_Str");
    }
  }
 else   if (indexMetadata.getType() == IndexType.CUSTOM) {
    indexDBObject=getCustomIndexDBObject(indexMetadata);
  }
 else {
    String msg="String_Node_Str" + indexMetadata.getType().toString() + "String_Node_Str";
    logger.error(msg);
    throw new MongoValidationException(msg);
  }
  return indexDBObject;
}

Fixed version (ground truth):
/** 
 * Creates the Mongo index based on the index metadata options.
 * @param indexMetadata the index metadata
 * @return the Mongo index
 * @throws MongoValidationException the unsupported exception
 */
public static DBObject getIndexDBObject(IndexMetadata indexMetadata) throws MongoValidationException {
  IndexType indexType=indexMetadata.getType();
  DBObject indexDBObject=new BasicDBObject();
  if (indexType == IndexType.DEFAULT) {
    for (    ColumnMetadata columnMeta : indexMetadata.getColumns().values()) {
      indexDBObject.put(columnMeta.getName().getName(),1);
    }
  }
 else   if (indexType == IndexType.FULL_TEXT) {
    for (    ColumnMetadata columnMeta : indexMetadata.getColumns().values()) {
      indexDBObject.put(columnMeta.getName().getName(),"String_Node_Str");
    }
  }
 else   if (indexMetadata.getType() == IndexType.CUSTOM) {
    indexDBObject=getCustomIndexDBObject(indexMetadata);
  }
 else {
    String msg="String_Node_Str" + indexMetadata.getType().toString() + "String_Node_Str";
    LOGGER.error(msg);
    throw new MongoValidationException(msg);
  }
  return indexDBObject;
}
Program: 168459
Project: 168459
Buggy source:
private boolean containsAnInnerRelation(Selector left,Selector right) throws ExecutionException {
  if (right.getType() == SelectorType.RELATION) {
    String column=(String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN);
    RelationSelector rightSelector=(RelationSelector)right;
    String innerRelationColumn=(String)SelectorHelper.getRestrictedValue(rightSelector.getRelation().getLeftTerm(),SelectorType.COLUMN);
    if (column.equals(innerRelationColumn)) {
      return true;
    }
 else {
      String msg="String_Node_Str" + column + "String_Node_Str"+ innerRelationColumn;
      logger.error(msg);
      throw new MongoValidationException(msg);
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean containsAnInnerRelation(Selector left,Selector right) throws ExecutionException {
  if (right.getType() == SelectorType.RELATION) {
    String column=(String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN);
    RelationSelector rightSelector=(RelationSelector)right;
    String innerRelationColumn=(String)SelectorHelper.getRestrictedValue(rightSelector.getRelation().getLeftTerm(),SelectorType.COLUMN);
    if (column.equals(innerRelationColumn)) {
      return true;
    }
 else {
      String msg="String_Node_Str" + column + "String_Node_Str"+ innerRelationColumn;
      LOGGER.error(msg);
      throw new MongoValidationException(msg);
    }
  }
  return false;
}
Program: 168460
Project: 168460
Buggy source:
private DBObject getNumberRelation(Selector left,Selector right) throws MongoValidationException, ExecutionException {
  Number number=retrieveNumberDataType(right,false);
  return new BasicDBObject((String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN),number);
}

Fixed version (ground truth):
private DBObject getNumberRelation(Selector left,Selector right) throws ExecutionException {
  Number number=retrieveNumberDataType(right,false);
  return new BasicDBObject((String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN),number);
}
Program: 168461
Project: 168461
Buggy source:
/** 
 * Checks if the column type is supported in the keys.
 * @param columnType the columnType type
 * @param cellValue the cell value
 * @throws MongoValidationException if the type is not supported
 * @throws ExecutionException
 */
private static Number retrieveNumberDataType(Selector selector,boolean isDecrement) throws MongoValidationException, ExecutionException {
  Number number=null;
switch (selector.getType()) {
case FLOATING_POINT:
    double dValue=(double)SelectorHelper.getRestrictedValue(selector,SelectorType.FLOATING_POINT);
  number=(isDecrement) ? -dValue : dValue;
break;
case INTEGER:
long iValue=(long)SelectorHelper.getRestrictedValue(selector,SelectorType.INTEGER);
number=(isDecrement) ? -iValue : iValue;
break;
default :
String msg="String_Node_Str" + selector.getType().toString();
logger.error(msg);
throw new MongoValidationException(msg);
}
return number;
}

Fixed version (ground truth):
/** 
 * Checks if the column type is supported in the keys.
 * @param columnType the columnType type
 * @param cellValue the cell value
 * @throws ExecutionException if the conversion fails
 */
private static Number retrieveNumberDataType(Selector selector,boolean isDecrement) throws ExecutionException {
  Number number=null;
switch (selector.getType()) {
case FLOATING_POINT:
    double dValue=(double)SelectorHelper.getRestrictedValue(selector,SelectorType.FLOATING_POINT);
  number=(isDecrement) ? -dValue : dValue;
break;
case INTEGER:
long iValue=(long)SelectorHelper.getRestrictedValue(selector,SelectorType.INTEGER);
number=(isDecrement) ? -iValue : iValue;
break;
default :
String msg="String_Node_Str" + selector.getType().toString();
LOGGER.error(msg);
throw new MongoValidationException(msg);
}
return number;
}
Program: 168462
Project: 168462
Buggy source:
private DBObject getIncrementalRelation(Selector left,Selector right,boolean isDecrement) throws ExecutionException, MongoValidationException {
  Number number=retrieveNumberDataType(right,isDecrement);
  return new BasicDBObject((String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN),number);
}

Fixed version (ground truth):
private DBObject getIncrementalRelation(Selector left,Selector right,boolean isDecrement) throws ExecutionException {
  Number number=retrieveNumberDataType(right,isDecrement);
  return new BasicDBObject((String)SelectorHelper.getRestrictedValue(left,SelectorType.COLUMN),number);
}
Program: 168463
Project: 168463
Buggy source:
/** 
 * Instantiates a new aggregation logical workflow executor.
 * @param logicalWorkflowParsed the logical workflow parsed
 * @throws MongoValidationException if the query specified in the logical workflow is not supported
 * @throws ExecutionException if the execution fails
 * @throws UnsupportedException if the specified operation is not supported.
 */
public AggregationLogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws MongoValidationException, ExecutionException, UnsupportedException {
  super(logicalWorkflowParsed);
}

Fixed version (ground truth):
/** 
 * Instantiates a new aggregation logical workflow executor.
 * @param logicalWorkflowParsed the logical workflow parsed
 * @throws ExecutionException if the execution fails or if the query specified in the logical workflow is not supported
 * @throws UnsupportedException if the specified operation is not supported.
 */
public AggregationLogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws ExecutionException, UnsupportedException {
  super(logicalWorkflowParsed);
}
Program: 168464
Project: 168464
Buggy source:
@Override protected void buildQuery() throws MongoValidationException, ExecutionException, UnsupportedException {
  query=new ArrayList<DBObject>();
  if (logicalWorkflowData.getProject() != null) {
    query.add(buildProject(true));
  }
  if (!logicalWorkflowData.getFilter().isEmpty()) {
    query.add(buildFilter(true));
  }
  if (logicalWorkflowData.getGroupBy() != null) {
    query.add(buildGroupBy());
  }
  if (logicalWorkflowData.getOrderBy() != null) {
    query.add(buildOrderBy(true));
  }
  if (logicalWorkflowData.getLimit() != null) {
    query.add(buildLimit());
  }
}

Fixed version (ground truth):
@Override protected void buildQuery() throws ExecutionException, UnsupportedException {
  query=new ArrayList<DBObject>();
  if (logicalWorkflowData.getProject() != null) {
    query.add(buildProject(true));
  }
  if (!logicalWorkflowData.getFilter().isEmpty()) {
    query.add(buildFilter(true));
  }
  if (logicalWorkflowData.getGroupBy() != null) {
    query.add(buildGroupBy());
  }
  if (logicalWorkflowData.getOrderBy() != null) {
    query.add(buildOrderBy(true));
  }
  if (logicalWorkflowData.getLimit() != null) {
    query.add(buildLimit());
  }
}
Program: 168465
Project: 168465
Buggy source:
/** 
 * Execute an aggregation query.
 * @param mongoClient the MongoDB client.
 * @return the Crossdata ResultSet.
 * @throws ExecutionException if the query specified in the logical workflow is not supported.
 * @throws MongoExecutionException if the execution fails.
 */
@Override public ResultSet executeQuery(MongoClient mongoClient) throws MongoExecutionException, ExecutionException {
  DB db=mongoClient.getDB(logicalWorkflowData.getProject().getCatalogName());
  DBCollection collection=db.getCollection(logicalWorkflowData.getProject().getTableName().getName());
  ResultSet resultSet=new ResultSet();
  resultSet.setColumnMetadata(MetaResultUtils.createMetadata(logicalWorkflowData.getProject(),logicalWorkflowData.getSelect()));
  try {
    int stage=1;
    for (    DBObject aggregationStage : query) {
      logger.debug("String_Node_Str" + (stage++) + "String_Node_Str"+ aggregationStage);
    }
    AggregationOutput aggOutput=collection.aggregate(query);
    for (    DBObject result : aggOutput.results()) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + result);
      }
      resultSet.add(MetaResultUtils.createRowWithAlias(result,logicalWorkflowData.getSelect()));
    }
  }
 catch (  MongoException mongoException) {
    logger.error("String_Node_Str" + mongoException.getMessage());
    throw new MongoExecutionException(mongoException.getMessage(),mongoException);
  }
  return resultSet;
}

Fixed version (ground truth):
/** 
 * Execute an aggregation query.
 * @param mongoClient the MongoDB client.
 * @return the Crossdata ResultSet.
 * @throws ExecutionException if the execution fails.
 */
@Override public ResultSet executeQuery(MongoClient mongoClient) throws ExecutionException {
  DB db=mongoClient.getDB(logicalWorkflowData.getProject().getCatalogName());
  DBCollection collection=db.getCollection(logicalWorkflowData.getProject().getTableName().getName());
  ResultSet resultSet=new ResultSet();
  resultSet.setColumnMetadata(MetaResultUtils.createMetadata(logicalWorkflowData.getProject(),logicalWorkflowData.getSelect()));
  try {
    int stage=1;
    for (    DBObject aggregationStage : query) {
      logger.debug("String_Node_Str" + (stage++) + "String_Node_Str"+ aggregationStage);
    }
    AggregationOutput aggOutput=collection.aggregate(query);
    for (    DBObject result : aggOutput.results()) {
      if (logger.isDebugEnabled()) {
        logger.debug("String_Node_Str" + result);
      }
      resultSet.add(MetaResultUtils.createRowWithAlias(result,logicalWorkflowData.getSelect()));
    }
  }
 catch (  MongoException mongoException) {
    logger.error("String_Node_Str" + mongoException.getMessage());
    throw new MongoExecutionException(mongoException.getMessage(),mongoException);
  }
  return resultSet;
}
Program: 168466
Project: 168466
Buggy source:
/** 
 * Instantiates a new basic logical workflow executor.
 * @param logicalWorkflowParsed the logical workflow parsed
 * @throws MongoValidationException if the query specified in the logical workflow is not supported
 * @throws ExecutionException if the execution fails
 * @throws UnsupportedException if the specified operation is not supported.
 */
public BasicLogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws MongoValidationException, ExecutionException, UnsupportedException {
  super(logicalWorkflowParsed);
}

Fixed version (ground truth):
/** 
 * Instantiates a new basic logical workflow executor.
 * @param logicalWorkflowParsed the logical workflow parsed
 * @throws ExecutionException if the execution fails or the query specified in the logical workflow is not supported
 * @throws UnsupportedException if the specified operation is not supported.
 */
public BasicLogicalWorkflowExecutor(ProjectParsed logicalWorkflowParsed) throws ExecutionException, UnsupportedException {
  super(logicalWorkflowParsed);
}
Program: 168468
Project: 168468
Buggy source:
/** 
 * Instantiates a new Mongo query engine.
 * @param project the initial step of the logical workflow
 * @param connection the connection
 * @return the query result
 * @throws UnsupportedException if the specified operation is not supported
 * @throws ExecutionException 
 */
@Override public QueryResult execute(Project project,Connection<MongoClient> connection) throws UnsupportedException, ExecutionException {
  LogicalWorkflowExecutor executor=new LogicalWorkflowExecutor(project);
  ResultSet resultSet=executor.executeQuery((MongoClient)connection.getNativeConnection());
  return QueryResult.createQueryResult(resultSet);
}

Fixed version (ground truth):
/** 
 * Instantiates a new Mongo query engine.
 * @param project the initial step of the logical workflow
 * @param connection the connection
 * @return the query result
 * @throws UnsupportedException if the specified operation is not supported
 * @throws ExecutionException
 */
@Override public QueryResult execute(Project project,Connection<MongoClient> connection) throws UnsupportedException, ExecutionException {
  LogicalWorkflowExecutor executor=new LogicalWorkflowExecutor(project);
  ResultSet resultSet=executor.executeQuery((MongoClient)connection.getNativeConnection());
  return QueryResult.createQueryResult(resultSet);
}
Program: 168469
Project: 168469
Buggy source:
public static DBObject buildRenameColumnDBObject(String oldName,String newName){
  return new BasicDBObject(RENAME_COMMAND,new BasicDBObject(oldName,newName));
}

Fixed version (ground truth):
/** 
 * Builds a rename column DBOject.
 * @param oldName the old name
 * @param newName the new name
 * @return the DBObject
 */
public static DBObject buildRenameColumnDBObject(String oldName,String newName){
  return new BasicDBObject(RENAME_COMMAND,new BasicDBObject(oldName,newName));
}
Program: 168470
Project: 168470
Buggy source:
public static DBObject buildDropColumnDBObject(String name){
  return new BasicDBObject(DROP_COMMAND,new BasicDBObject(name,"String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Builds a DBObject to drop a column.
 * @param name the column name
 * @return the DBObject
 */
public static DBObject buildDropColumnDBObject(String name){
  return new BasicDBObject(DROP_COMMAND,new BasicDBObject(name,"String_Node_Str"));
}
Program: 168472
Project: 168472
Buggy source:
public DBObject build(){
  return relations;
}

Fixed version (ground truth):
/** 
 * Builds the update DBObject.
 * @return the DB object
 */
public DBObject build(){
  return relations;
}
Program: 168473
Project: 168473
Buggy source:
public UpdateDBObjectBuilder(){
  relations=new BasicDBObject();
}

Fixed version (ground truth):
/** 
 * Instantiates a new update DBObject builder.
 */
public UpdateDBObjectBuilder(){
  relations=new BasicDBObject();
}
Program: 168474
Project: 168474
Buggy source:
/** 
 * Checks if the column type is supported in the keys.
 * @param columnType the columnType type
 * @param cellValue the cell value
 * @throws MongoValidationException if the type is not supported
 * @throws ExecutionException
 */
private static Number retrieveNumberDataType(Selector selector,boolean isDecrement) throws MongoValidationException, ExecutionException {
  Number number=null;
switch (selector.getType()) {
case FLOATING_POINT:
    Double dValue=(Double)SelectorHelper.getRestrictedValue(selector,SelectorType.FLOATING_POINT);
  number=(isDecrement) ? -dValue : dValue;
case INTEGER:
Long iValue=(Long)SelectorHelper.getRestrictedValue(selector,SelectorType.INTEGER);
number=(isDecrement) ? -iValue : iValue;
break;
case STRING:
case ASTERISK:
case BOOLEAN:
case COLUMN:
case FUNCTION:
case RELATION:
default :
throw new MongoValidationException("String_Node_Str" + selector.getType().toString());
}
return number;
}

Fixed version (ground truth):
/** 
 * Checks if the column type is supported in the keys.
 * @param columnType the columnType type
 * @param cellValue the cell value
 * @throws MongoValidationException if the type is not supported
 * @throws ExecutionException
 */
private static Number retrieveNumberDataType(Selector selector,boolean isDecrement) throws MongoValidationException, ExecutionException {
  Number number=null;
switch (selector.getType()) {
case FLOATING_POINT:
    double dValue=(double)SelectorHelper.getRestrictedValue(selector,SelectorType.FLOATING_POINT);
  number=(isDecrement) ? -dValue : dValue;
break;
case INTEGER:
long iValue=(long)SelectorHelper.getRestrictedValue(selector,SelectorType.INTEGER);
number=(isDecrement) ? -iValue : iValue;
break;
default :
throw new MongoValidationException("String_Node_Str" + selector.getType().toString());
}
return number;
}
Program: 168475
Project: 168475
Buggy source:
/** 
 * Instantiates a new logical workflow executor ready for the execution.
 * @param initialProject the initial project
 * @throws UnsupportedException if the query specified in the logical workflow is not supported
 * @throws ExecutionException 
 */
public LogicalWorkflowExecutor(LogicalStep initialProject) throws UnsupportedException, ExecutionException {
  readLogicalWorkflow(initialProject);
  aggregationRequired();
  buildQuery();
}

Fixed version (ground truth):
/** 
 * Instantiates a new logical workflow executor ready for the execution.
 * @param initialProject the initial project
 * @throws UnsupportedException if the query specified in the logical workflow is not supported
 * @throws ExecutionException
 */
public LogicalWorkflowExecutor(LogicalStep initialProject) throws UnsupportedException, ExecutionException {
  readLogicalWorkflow(initialProject);
  aggregationRequired();
  buildQuery();
}
Program: 168476
Project: 168476
Buggy source:
/** 
 * Creates the corresponding MongoDB query.
 * @throws MongoValidationException if the query specified in the logical workflow is not supported
 * @throws ExecutionException 
 */
private void buildQuery() throws MongoValidationException, ExecutionException {
  query=new ArrayList<DBObject>();
  if (isAggregationRequired()) {
    if (!filterList.isEmpty()) {
      query.add(buildFilter());
    }
    if (groupBy != null) {
      query.add(buildGroupBy());
    }
    if (limit != null) {
      query.add(buildLimit());
    }
  }
 else {
    query.add(buildFilter());
  }
}

Fixed version (ground truth):
/** 
 * Creates the corresponding MongoDB query.
 * @throws MongoValidationException if the query specified in the logical workflow is not supported
 * @throws ExecutionException
 */
private void buildQuery() throws MongoValidationException, ExecutionException {
  query=new ArrayList<DBObject>();
  if (isAggregationRequired()) {
    if (!filterList.isEmpty()) {
      query.add(buildFilter());
    }
    if (groupBy != null) {
      query.add(buildGroupBy());
    }
    if (limit != null) {
      query.add(buildLimit());
    }
  }
 else {
    query.add(buildFilter());
  }
}