Merge branch 'stable-2.12' into stable-2.13

* stable-2.12:
  Prevent limit of search outbounding max int value
  Fix NullPointerException on computing task name
  Double-check change data in cleaning up task

Change-Id: I60e321692b19b21f043aad3a59af9483b79a089e
This commit is contained in:
David Pursehouse 2016-09-01 09:59:56 +09:00
commit e8a7b624ed
2 changed files with 16 additions and 0 deletions

View File

@ -322,6 +322,9 @@ public class LuceneChangeIndex implements ChangeIndex {
IndexSearcher[] searchers = new IndexSearcher[indexes.size()]; IndexSearcher[] searchers = new IndexSearcher[indexes.size()];
try { try {
int realLimit = opts.start() + opts.limit(); int realLimit = opts.start() + opts.limit();
if (Integer.MAX_VALUE - opts.limit() < opts.start()) {
realLimit = Integer.MAX_VALUE;
}
TopFieldDocs[] hits = new TopFieldDocs[indexes.size()]; TopFieldDocs[] hits = new TopFieldDocs[indexes.size()];
for (int i = 0; i < indexes.size(); i++) { for (int i = 0; i < indexes.size(); i++) {
searchers[i] = indexes.get(i).acquire(); searchers[i] = indexes.get(i).acquire();

View File

@ -73,6 +73,11 @@ public class AbandonUtil {
int count = 0; int count = 0;
for (ChangeData cd : changesToAbandon) { for (ChangeData cd : changesToAbandon) {
try { try {
if (noNeedToAbandon(cd, query)){
log.debug("Change data \"{}\" does not satisfy the query \"{}\" any"
+ " more, hence skipping it in clean up", cd, query);
continue;
}
abandon.abandon(changeControl(cd), cfg.getAbandonMessage()); abandon.abandon(changeControl(cd), cfg.getAbandonMessage());
count++; count++;
} catch (ResourceConflictException e) { } catch (ResourceConflictException e) {
@ -90,6 +95,14 @@ public class AbandonUtil {
} }
} }
private boolean noNeedToAbandon(ChangeData cd, String query)
throws OrmException, QueryParseException {
String newQuery = query + " change:" + cd.getId();
List<ChangeData> changesToAbandon = queryProcessor.enforceVisibility(false)
.query(queryBuilder.parse(newQuery)).entities();
return changesToAbandon.isEmpty();
}
private ChangeControl changeControl(ChangeData cd) throws OrmException { private ChangeControl changeControl(ChangeData cd) throws OrmException {
return cd.changeControl(internalUserFactory.create()); return cd.changeControl(internalUserFactory.create());
} }