reschke commented on code in PR #838:
URL: https://github.com/apache/jackrabbit-oak/pull/838#discussion_r1091613268


##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/FieldFactory.java:
##########
@@ -186,7 +187,17 @@ public static Long dateToLong(String date){
             return null;
         }
         //TODO OAK-2204 - Should we change the precision to lower resolution
-        return ISO8601.parse(date).getTimeInMillis();
+        Calendar c = ISO8601.parse(date);
+        if (c != null) {
+            return c.getTimeInMillis();
+        } else {
+            // ISO8601.parse returns null in case of multiple exceptions like 
IllegalFormatException, IndexOutOfBoundsException, NumberFormatException etc
+            // However returning null for us would basically store a null 
value in the document (which seems wrong).
+            // So throwing an unchecked exception here with a proper 
description.
+            // Earlier such a situation was leading to an NPE which was 
confusing to understand.
+            // Refer 
https://jackrabbit.apache.org/api/2.12/index.html?org/apache/jackrabbit/util/ISO8601.html

Review Comment:
   please cite a non-obsoleted version of the Jackrabbit API :-)



-- 
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