Print proper name for QuerySource tasks in show-queue command

Before this commit, the tasks name were printed like this:

com.google.gerrit.lucene.LuceneChangeIndex$QuerySource$1@77352d29

Now, the Lucene query is printed, example:

((status:new OR status:draft) owner:1000001)

Change-Id: I9a08a8eef08af5dba9b0948b9ae445a807fe8b87
This commit is contained in:
Hugo Arès 2016-09-14 09:00:46 -04:00
parent ee24b3c547
commit f00dee4c8e
1 changed files with 14 additions and 6 deletions

View File

@ -367,8 +367,7 @@ public class LuceneChangeIndex implements ChangeIndex {
if (!Sets.intersection(statuses, CLOSED_STATUSES).isEmpty()) {
indexes.add(closedIndex);
}
return new QuerySource(indexes, queryBuilder.toQuery(p), opts,
getSort());
return new QuerySource(indexes, p, opts, getSort());
}
@Override
@ -401,14 +400,18 @@ public class LuceneChangeIndex implements ChangeIndex {
private class QuerySource implements ChangeDataSource {
private final List<SubIndex> indexes;
private final Predicate<ChangeData> predicate;
private final Query query;
private final QueryOptions opts;
private final Sort sort;
private QuerySource(List<SubIndex> indexes, Query query, QueryOptions opts,
Sort sort) {
private QuerySource(List<SubIndex> indexes, Predicate<ChangeData> predicate,
QueryOptions opts, Sort sort) throws QueryParseException {
this.indexes = indexes;
this.query = checkNotNull(query, "null query from Lucene");
this.predicate = predicate;
this.query = checkNotNull(queryBuilder.toQuery(predicate),
"null query from Lucene");
this.opts = opts;
this.sort = sort;
}
@ -425,7 +428,7 @@ public class LuceneChangeIndex implements ChangeIndex {
@Override
public String toString() {
return query.toString();
return predicate.toString();
}
@Override
@ -440,6 +443,11 @@ public class LuceneChangeIndex implements ChangeIndex {
public List<Document> call() throws OrmException {
return doRead();
}
@Override
public String toString() {
return predicate.toString();
}
}));
}