nfsantos commented on code in PR #1645:
URL: https://github.com/apache/jackrabbit-oak/pull/1645#discussion_r1718339587


##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneDocumentMaker.java:
##########
@@ -299,19 +301,43 @@ protected boolean indexTypeOrderedFields(Document doc, 
String pname, int tag, Pr
                     doc.add(f);
                     fieldAdded = true;
                 } else {
-                    long now = System.currentTimeMillis();
-                    if (now > lastDuplicateWarning + 
DUPLICATE_WARNING_INTERVAL_MS) {
+                    if (!LOG_SILENCER.silence(LOG_KEY_DUPLICATE)) {
                         log.warn("Duplicate value for ordered field {}; 
ignoring. Possibly duplicate index definition.", f.name());
-                        lastDuplicateWarning = now;
                     }
                 }
             }
         } catch (Exception e) {
-            log.warn(
-                    "[{}] Ignoring ordered property. Could not convert 
property {} of type {} to type {} for path {}",
-                    getIndexName(), pname,
-                    Type.fromTag(property.getType().tag(), false),
-                    Type.fromTag(tag, false), path, e);
+            String message = e.getMessage();
+            String key = null;
+            // This is a known warning, one of:
+            // - IllegalArgumentException: Not a date string
+            // - RuntimeException: Unable to parse the provided date field
+            // - NumberFormatException: For input string
+            // For these we do not log a stack trace, and we only log once 
every 10 seconds
+            // (the location of the code can be found if needed, as it's in 
Oak)
+            if (message.startsWith("Not a date string")) {
+                key = LOG_KEY_NOT_A_DATE_STRING;
+            } else if (message.startsWith("Unable to parse the provided date 
field")) {
+                key = LOG_KEY_UNABLE_TO_PARSE;
+            } else if (message.startsWith("For input string")) {
+                key = LOG_KEY_FOR_INPUT_STRING;
+            }

Review Comment:
   This could be simplified a bit, something like:
   ```
   List<String> errorMessagePrefixes = List.of("Not a date string", "Unable to 
parse the provided date field", "For input string");
   ...
   String key = errorMessagePrefixes.stream().find(t -> 
message.startsWith(t))...
   ```
   



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