Program: 13163
Project: 13163
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public Promise<QueryResponse,ResourceException> queryCollection(final Context context,final QueryRequest request,final QueryResourceHandler handler){
  try {
    if (request.getQueryExpression() != null) {
      return new BadRequestException(HttpUtils.PARAM_QUERY_EXPRESSION + "String_Node_Str").asPromise();
    }
    final QueryRequest queryRequest=Requests.newQueryRequest(REPO_RESOURCE_PATH);
    final boolean queryAllIds=ServerConstants.QUERY_ALL_IDS.equals(request.getQueryId());
    if (request.getQueryId() != null) {
      request.setQueryFilter(QueryFilter.<JsonPointer>alwaysTrue());
      if (ServerConstants.QUERY_ALL_IDS.equals(request.getQueryId())) {
        request.addField(FIELD_ID);
      }
 else       if (!"String_Node_Str".equals(request.getQueryId())) {
        return new BadRequestException("String_Node_Str" + HttpUtils.PARAM_QUERY_ID + "String_Node_Str").asPromise();
      }
    }
    queryRequest.setQueryFilter(request.getQueryFilter());
    queryRequest.setPageSize(request.getPageSize());
    queryRequest.setPagedResultsOffset(request.getPagedResultsOffset());
    queryRequest.setPagedResultsCookie(request.getPagedResultsCookie());
    queryRequest.setTotalPagedResultsPolicy(request.getTotalPagedResultsPolicy());
    queryRequest.addSortKey(request.getSortKeys().toArray(new SortKey[request.getSortKeys().size()]));
    for (    String key : request.getAdditionalParameters().keySet()) {
      queryRequest.setAdditionalParameter(key,request.getAdditionalParameter(key));
    }
    QueryFilter<JsonPointer> filter=QueryFilter.and(QueryFilter.equalTo(new JsonPointer(isReverse ? REPO_FIELD_SECOND_ID : REPO_FIELD_FIRST_ID),firstResourcePath(context,request)),QueryFilter.equalTo(new JsonPointer(REPO_FIELD_FIRST_PROPERTY_NAME),propertyName));
    if (request.getQueryFilter() != null) {
      filter=QueryFilter.and(filter,asRelationshipQueryFilter(request.getQueryFilter()));
    }
    queryRequest.setQueryFilter(filter);
    final Promise<QueryResponse,ResourceException> response=getConnection().queryAsync(context,queryRequest,new QueryResourceHandler(){
      @Override public boolean handleResource(      ResourceResponse resource){
        ResourceResponse filteredResourceResponse=FORMAT_RESPONSE_NO_EXCEPTION.apply(resource);
        if (queryAllIds) {
          filteredResourceResponse.addField(FIELD_ID);
          return handler.handleResource(filteredResourceResponse);
        }
        try {
          filteredResourceResponse=expandFields(context,request,filteredResourceResponse).getOrThrow();
        }
 catch (        Exception e) {
          logger.error("String_Node_Str" + e.getMessage(),e);
        }
        return handler.handleResource(filteredResourceResponse);
      }
    }
);
    if (context.containsContext(ManagedObjectSetContext.class)) {
      return response;
    }
    QueryResponse result=response.getOrThrow();
    final ResourceResponse value=getManagedObject(context);
    activityLogger.log(context,request,"String_Node_Str",getManagedObjectPath(context),null,value.getContent(),Status.SUCCESS);
    return newResultPromise(result);
  }
 catch (  ResourceException e) {
    return e.asPromise();
  }
catch (  Exception e) {
    return new InternalServerErrorException(e.getMessage(),e).asPromise();
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public Promise<QueryResponse,ResourceException> queryCollection(final Context context,final QueryRequest request,final QueryResourceHandler handler){
  try {
    if (request.getQueryExpression() != null) {
      return new BadRequestException(HttpUtils.PARAM_QUERY_EXPRESSION + "String_Node_Str").asPromise();
    }
    final QueryRequest queryRequest=Requests.newQueryRequest(REPO_RESOURCE_PATH);
    final boolean queryAllIds=ServerConstants.QUERY_ALL_IDS.equals(request.getQueryId());
    if (request.getQueryId() != null) {
      request.setQueryFilter(QueryFilter.<JsonPointer>alwaysTrue());
      if (ServerConstants.QUERY_ALL_IDS.equals(request.getQueryId())) {
        request.addField(FIELD_ID);
      }
 else       if (!"String_Node_Str".equals(request.getQueryId())) {
        return new BadRequestException("String_Node_Str" + HttpUtils.PARAM_QUERY_ID + "String_Node_Str").asPromise();
      }
    }
    queryRequest.setQueryFilter(request.getQueryFilter());
    queryRequest.setPageSize(request.getPageSize());
    queryRequest.setPagedResultsOffset(request.getPagedResultsOffset());
    queryRequest.setPagedResultsCookie(request.getPagedResultsCookie());
    queryRequest.setTotalPagedResultsPolicy(request.getTotalPagedResultsPolicy());
    queryRequest.addSortKey(request.getSortKeys().toArray(new SortKey[request.getSortKeys().size()]));
    for (    String key : request.getAdditionalParameters().keySet()) {
      queryRequest.setAdditionalParameter(key,request.getAdditionalParameter(key));
    }
    QueryFilter<JsonPointer> filter=QueryFilter.and(QueryFilter.equalTo(new JsonPointer(isReverse ? REPO_FIELD_SECOND_ID : REPO_FIELD_FIRST_ID),firstResourcePath(context,request)),QueryFilter.equalTo(new JsonPointer(REPO_FIELD_FIRST_PROPERTY_NAME),propertyName));
    if (request.getQueryFilter() != null) {
      filter=QueryFilter.and(filter,asRelationshipQueryFilter(isReverse,request.getQueryFilter()));
    }
    queryRequest.setQueryFilter(filter);
    final Promise<QueryResponse,ResourceException> response=getConnection().queryAsync(context,queryRequest,new QueryResourceHandler(){
      @Override public boolean handleResource(      ResourceResponse resource){
        ResourceResponse filteredResourceResponse=FORMAT_RESPONSE_NO_EXCEPTION.apply(resource);
        if (queryAllIds) {
          filteredResourceResponse.addField(FIELD_ID);
          return handler.handleResource(filteredResourceResponse);
        }
        try {
          filteredResourceResponse=expandFields(context,request,filteredResourceResponse).getOrThrow();
        }
 catch (        Exception e) {
          logger.error("String_Node_Str" + e.getMessage(),e);
        }
        return handler.handleResource(filteredResourceResponse);
      }
    }
);
    if (context.containsContext(ManagedObjectSetContext.class)) {
      return response;
    }
    QueryResponse result=response.getOrThrow();
    final ResourceResponse value=getManagedObject(context);
    activityLogger.log(context,request,"String_Node_Str",getManagedObjectPath(context),null,value.getContent(),Status.SUCCESS);
    return newResultPromise(result);
  }
 catch (  ResourceException e) {
    return e.asPromise();
  }
catch (  Exception e) {
    return new InternalServerErrorException(e.getMessage(),e).asPromise();
  }
}