LUCENE-7567: don't clone BooleanClause in builder

This commit is contained in:
yonik 2016-11-20 22:56:38 -05:00
parent df6d86d5f6
commit 3e2800ea04
1 changed files with 5 additions and 6 deletions

View File

@ -121,7 +121,10 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
*/
public Builder add(BooleanClause clause) {
add(clause.getQuery(), clause.getOccur());
if (clauses.size() >= maxClauseCount) {
throw new TooManyClauses();
}
clauses.add(clause);
return this;
}
@ -132,11 +135,7 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
* @throws TooManyClauses if the new number of clauses exceeds the maximum clause number
*/
public Builder add(Query query, Occur occur) {
if (clauses.size() >= maxClauseCount) {
throw new TooManyClauses();
}
clauses.add(new BooleanClause(query, occur));
return this;
return add(new BooleanClause(query, occur));
}
/** Create a new {@link BooleanQuery} based on the parameters that have