thomasmueller commented on code in PR #2746:
URL: https://github.com/apache/jackrabbit-oak/pull/2746#discussion_r2853070356


##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/UnionQueryImpl.java:
##########
@@ -568,16 +568,16 @@ public int compare(ResultRowImpl left, ResultRowImpl 
right) {
 
     /**
      * @param row the result row
-     * @return the jcr:score as a double
-     * Precondition: {@link #isScorePresent(Query)} must be true. If the row 
lacks a jcr:score, 0.0 is returned and
-     * the issue is logged.
+     * @return the jcr:score as a double, or 0.0 if the row lacks a score value
      */
     private double getScoreFromRow(ResultRowImpl row) {
         try {
             PropertyValue scoreValue = row.getValue(QueryConstants.JCR_SCORE);
+            if (scoreValue == null) {
+                return 0.0;
+            }
             return scoreValue.getValue(Type.DOUBLE);
         } catch (IllegalArgumentException e) {
-            LOG.warn("Failed to get jcr:score for path={}", row.getPath(), e);

Review Comment:
   If it fails quite often, then we should probably change the code so that it 
first checks if the column is available, in order to _not_ throw an exception 
in the first place.



##########
oak-core/src/test/java/org/apache/jackrabbit/oak/query/UnionQueryTest.java:
##########
@@ -512,12 +552,19 @@ public MockQueryBuilder(boolean hasScore) {
         }
 
         public MockQueryBuilder addResult(String path, double score) {
+            if (!hasScore) {
+                throw new IllegalStateException("Cannot provide score");
+            }
+            return addResult(path, Double.valueOf(score));
+        }
+
+        public MockQueryBuilder addResult(String path, Double score) {
             if (!hasScore) {
                 throw new IllegalStateException("Cannot provide score");
             }
             PropertyValue[] values = new PropertyValue[] {
                     PropertyValues.newString(path),
-                    PropertyValues.newDouble(score)
+                    score == null ? null : PropertyValues.newDouble(score)

Review Comment:
   Yes, I see, you are right! Sorry I got confused.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to