Marvin created OAK-12051:
----------------------------

             Summary: Sorting Unions by Score: NullPointerException
                 Key: OAK-12051
                 URL: https://issues.apache.org/jira/browse/OAK-12051
             Project: Jackrabbit Oak
          Issue Type: Bug
          Components: query
            Reporter: Marvin


With ticket OAK-11949 we introduced the feature that union queries are sorted 
by score, instead of simply concatenating them. However, turning on the feature 
toggle causes NullPointerExceptions in some rare cases. The problem occurs if 
there is a score column, but accessing a score of that column returns Null. 
This can happen if, for example, there is a union between three queries, of 
which at least one has scores, and at least one doesn't have, and those two 
results are merged first. 
{code:java}
This happens when the product tests make the following request 
/libs/granite/security/search/authorizables.json?offset=0&query=%7B"condition"%3A%5B%7B"named"%3A"testGroup07fe1bae-63c5-4fb1-8924-a345f2f4451c"%7D%5D%7D
 and fails consistently causing CreatePageAsAuthorUserIT#testCreatePageAsAuthor 
to fail. Query that fails:[rep:Authorizable] as [a] /* property authorizableId 
indexDefinition: /oak:index/authorizableId values: 
'testGroup07fe1bae-63c5-4fb1-8924-a345f2f4451c' estimatedCost: 2.0 */ union 
[rep:Authorizable] as [a] /* property principalName indexDefinition: 
/oak:index/principalName values: 
'testGroup07fe1bae-63c5-4fb1-8924-a345f2f4451c' estimatedCost: 2.0 */ union 
[rep:Authorizable] as [a] /* lucene:authorizables indexDefinition: 
/oak:index/authorizables estimatedEntries: 167 luceneQuery: :ancestors:/home */ 
{code}
 
{code:java}
[52.177.162.196 [1767767494687] GET 
/libs/granite/security/search/authorizables.json HTTP/1.1] 
org.apache.sling.servlets.resolver.internal.SlingServletResolver Original error 
class java.lang.NullPointerException java.lang.NullPointerException: Cannot 
invoke 
"org.apache.jackrabbit.oak.api.PropertyValue.getValue(org.apache.jackrabbit.oak.api.Type)"
 because "scoreValue" is null at 
org.apache.jackrabbit.oak.query.UnionQueryImpl.getScoreFromRow(UnionQueryImpl.java:578)
 [org.apache.jackrabbit.oak-core:1.88.0.T20251029163355-5d5086d] at 
org.apache.jackrabbit.oak.query.UnionQueryImpl$2.compare(UnionQueryImpl.java:564)
 [org.apache.jackrabbit.oak-core:1.88.0.T20251029163355-5d5086d] at 
org.apache.jackrabbit.oak.query.UnionQueryImpl$2.compare(UnionQueryImpl.java:561)
 [org.apache.jackrabbit.oak-core:1.88.0.T20251029163355-5d5086d] {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to