sigram commented on code in PR #2403:
URL: https://github.com/apache/solr/pull/2403#discussion_r1567091001


##########
solr/core/src/java/org/apache/solr/search/QueryLimits.java:
##########
@@ -108,22 +110,31 @@ public String formatExceptionMessage(String label) {
    * @throws QueryLimitsExceededException if {@link 
CommonParams#PARTIAL_RESULTS} request parameter
    *     is false and limits have been reached.
    */
-  public boolean maybeExitWithPartialResults(String label) throws 
QueryLimitsExceededException {
+  public boolean maybeExitWithPartialResults(Supplier<String> label)
+      throws QueryLimitsExceededException {
     if (isLimitsEnabled() && shouldExit()) {
       if (allowPartialResults) {
         if (rsp != null) {
           rsp.setPartialResults();
-          rsp.addPartialResponseDetail(formatExceptionMessage(label));
+          if 
(rsp.getResponseHeader().get(RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY) == 
null) {
+            // don't want to add duplicate keys. Although technically legal, 
there's a strong risk
+            // that clients won't anticipate it and break.
+            rsp.addPartialResponseDetail(formatExceptionMessage(label.get()));
+          }
         }
         return true;
       } else {
-        throw new QueryLimitsExceededException(formatExceptionMessage(label));
+        throw new 
QueryLimitsExceededException(formatExceptionMessage(label.get()));
       }
     } else {
       return false;
     }
   }
 
+  public boolean maybeExitWithPartialResults(String label) throws 
QueryLimitsExceededException {

Review Comment:
   I think we should add some javadoc here that explains why we have two 
different methods for doing essentially the same work, and when to prefer one 
over the other.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to