Merge branch 'stable-2.12'

* stable-2.12:
  Make VelocityRuntimeProvider singleton, not RuntimeInstance
  Throw QueryParseException if the created phrase query is null

Change-Id: I2ca604abd6bc0c14b95ea67fee4e63f8088621ca
This commit is contained in:
David Pursehouse
2016-08-01 09:25:03 +09:00
3 changed files with 9 additions and 3 deletions

View File

@@ -241,7 +241,12 @@ public class QueryBuilder<V> {
throw new QueryParseException(
"Full-text search over empty string not supported");
}
return queryBuilder.createPhraseQuery(p.getField().getName(), value);
Query query = queryBuilder.createPhraseQuery(p.getField().getName(), value);
if (query == null) {
throw new QueryParseException(
"Cannot create full-text query with value: " + value);
}
return query;
}
public int toIndexTimeInMinutes(Date ts) {

View File

@@ -271,8 +271,7 @@ public class GerritGlobalModule extends FactoryModule {
bind(ApprovalsUtil.class);
bind(RuntimeInstance.class)
.toProvider(VelocityRuntimeProvider.class)
.in(SINGLETON);
.toProvider(VelocityRuntimeProvider.class);
bind(FromAddressGenerator.class).toProvider(
FromAddressGeneratorProvider.class).in(SINGLETON);
bind(Boolean.class).annotatedWith(DisableReverseDnsLookup.class)

View File

@@ -18,6 +18,7 @@ import com.google.gerrit.server.config.SitePaths;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.ProvisionException;
import com.google.inject.Singleton;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.RuntimeInstance;
@@ -30,6 +31,7 @@ import java.nio.file.Files;
import java.util.Properties;
/** Configures Velocity template engine for sending email. */
@Singleton
public class VelocityRuntimeProvider implements Provider<RuntimeInstance> {
private final SitePaths site;