[
https://issues.apache.org/jira/browse/SOLR-15031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pieter updated SOLR-15031:
--------------------------
Description:
When parsing a sub query in a function query,
{{FunctionQParser#parseValueSource}} does not check if the produced query
object is null. When it is, it just wraps a null in a {{QueryValueSource}}
object. This is a cause for NPE's in code consuming that object. Parsed queries
can be null, for example when the query string only contains stopwords, so we
need handle that condition.
h3. Steps to reproduce the issue
# Start solr with the techproducts example collection: {{solr start -e
techproducts}}
# Add a stopword to
SOLR_DIR/example/techproducts/solr/techproducts/conf/stopwords.txt, for example
"at"
# Execute a function query:
http://localhost:8983/solr/techproducts/select?fieldquery={!field%20f=features%20v=%27%22at%22%27}&q={!func}%20if($fieldquery,1,0)
The following stacktrace is produced:
{code}
2020-12-03 13:35:38.868 INFO (qtp2095677157-21) [ x:techproducts]
o.a.s.c.S.Request [techproducts] webapp=/solr path=/select
params={q={!func}+if($fieldquery,1,0)&fieldquery={!field+f%3Dfeatures+v%3D'"at"'}}
status=500 QTime=34
2020-12-03 13:35:38.872 ERROR (qtp2095677157-21) [ x:techproducts]
o.a.s.s.HttpSolrCall null:java.lang.NullPointerException
at
org.apache.lucene.queries.function.valuesource.QueryValueSource.hashCode(QueryValueSource.java:63)
at
org.apache.lucene.queries.function.valuesource.IfFunction.hashCode(IfFunction.java:129)
at
org.apache.lucene.queries.function.FunctionQuery.hashCode(FunctionQuery.java:176)
at org.apache.solr.search.QueryResultKey.<init>(QueryResultKey.java:53)
at
org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1341)
at
org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:580)
{code}
was:When parsing a sub query in a function query,
{{FunctionQParser#parseValueSource}} does not check if the produced query
object is null. When it is, it just wraps a null in a {{QueryValueSource}}
object. This is a cause for NPE's in code consuming that object. Parsed queries
can be null, for example when the query string only contains stopwords (see
steps to reproduce for an example), so we need handle that condition.
> NPE caused by FunctionQParser returning a null ValueSource
> ----------------------------------------------------------
>
> Key: SOLR-15031
> URL: https://issues.apache.org/jira/browse/SOLR-15031
> Project: Solr
> Issue Type: Bug
> Security Level: Public(Default Security Level. Issues are Public)
> Reporter: Pieter
> Priority: Minor
>
> When parsing a sub query in a function query,
> {{FunctionQParser#parseValueSource}} does not check if the produced query
> object is null. When it is, it just wraps a null in a {{QueryValueSource}}
> object. This is a cause for NPE's in code consuming that object. Parsed
> queries can be null, for example when the query string only contains
> stopwords, so we need handle that condition.
> h3. Steps to reproduce the issue
> # Start solr with the techproducts example collection: {{solr start -e
> techproducts}}
> # Add a stopword to
> SOLR_DIR/example/techproducts/solr/techproducts/conf/stopwords.txt, for
> example "at"
> # Execute a function query:
> http://localhost:8983/solr/techproducts/select?fieldquery={!field%20f=features%20v=%27%22at%22%27}&q={!func}%20if($fieldquery,1,0)
> The following stacktrace is produced:
> {code}
> 2020-12-03 13:35:38.868 INFO (qtp2095677157-21) [ x:techproducts]
> o.a.s.c.S.Request [techproducts] webapp=/solr path=/select
> params={q={!func}+if($fieldquery,1,0)&fieldquery={!field+f%3Dfeatures+v%3D'"at"'}}
> status=500 QTime=34
> 2020-12-03 13:35:38.872 ERROR (qtp2095677157-21) [ x:techproducts]
> o.a.s.s.HttpSolrCall null:java.lang.NullPointerException
> at
> org.apache.lucene.queries.function.valuesource.QueryValueSource.hashCode(QueryValueSource.java:63)
> at
> org.apache.lucene.queries.function.valuesource.IfFunction.hashCode(IfFunction.java:129)
> at
> org.apache.lucene.queries.function.FunctionQuery.hashCode(FunctionQuery.java:176)
> at
> org.apache.solr.search.QueryResultKey.<init>(QueryResultKey.java:53)
> at
> org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1341)
> at
> org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:580)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]