From 48b026d5eedcfa2090596639dd5282fac18db40a Mon Sep 17 00:00:00 2001 From: Munendra S N Date: Tue, 2 Jul 2019 10:27:54 +0530 Subject: [PATCH] SOLR-13404: Fix NPE when group=true and no group.field is present * This was introduced in SOLR-12249 --- .../apache/solr/handler/component/QueryComponent.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java index 5f7b218e1a3..4461f1fc8c1 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -286,10 +286,13 @@ public class QueryComponent extends SearchComponent if (req.getCore().getCoreContainer().isZooKeeperAware()) { IndexSchema schema = rb.req.getSchema(); String[] fields = params.getParams(GroupParams.GROUP_FIELD); - for (String field : fields) { - SchemaField schemaField = schema.getField(field); - if (schemaField.getType().isTokenized() && (schemaField.getType() instanceof SortableTextField) == false) { - throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, String.format(Locale.ROOT, "Sorting on a tokenized field that is not a SortableTextField is not supported in cloud mode.")); + if (fields != null) { + for (String field : fields) { + SchemaField schemaField = schema.getField(field); + if (schemaField.getType().isTokenized() && (schemaField.getType() instanceof SortableTextField) == false) { + throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, String.format(Locale.ROOT, + "Sorting on a tokenized field that is not a SortableTextField is not supported in cloud mode.")); + } } } }