stillalex commented on code in PR #1632:
URL: https://github.com/apache/solr/pull/1632#discussion_r1296299519


##########
solr/core/src/java/org/apache/solr/servlet/ResponseUtils.java:
##########
@@ -96,6 +120,22 @@ public static int getErrorInfo(Throwable ex, 
NamedList<Object> info, Logger log)
    * @see #getErrorInfo(Throwable, NamedList, Logger)
    */
   public static ErrorInfo getTypedErrorInfo(Throwable ex, Logger log) {
+    return getTypedErrorInfo(ex, log, null);
+  }
+
+  /**
+   * Adds information about the given Throwable to a returned {@link ErrorInfo}
+   *
+   * <p>Primarily used by v2 API code, which can handle such typed information.
+   *
+   * <p>Status codes less than 100 are adjusted to be 500.
+   *
+   * <p>Stack trace will not be output if hideTrace=true OR system property
+   * solr.hideStackTrace=true.
+   *
+   * @see #getErrorInfo(Throwable, NamedList, Logger)
+   */
+  public static ErrorInfo getTypedErrorInfo(Throwable ex, Logger log, SolrCore 
core) {

Review Comment:
   same as above. pass the boolean only



##########
solr/core/src/java/org/apache/solr/servlet/ResponseUtils.java:
##########
@@ -42,6 +43,26 @@ private ResponseUtils() {}
    * @see #getTypedErrorInfo(Throwable, Logger)
    */
   public static int getErrorInfo(Throwable ex, NamedList<Object> info, Logger 
log) {
+    return getErrorInfo(ex, info, log, null);
+  }
+
+  /**
+   * Adds the given Throwable's message to the given NamedList.
+   *
+   * <p>Primarily used by v1 code; v2 endpoints or dispatch code should call 
{@link
+   * #getTypedErrorInfo(Throwable, Logger)}
+   *
+   * <p>If the response code is not a regular code, the Throwable's stack 
trace is both logged and
+   * added to the given NamedList.
+   *
+   * <p>Status codes less than 100 are adjusted to be 500.
+   *
+   * <p>Stack trace will not be output if hideTrace=true OR system property
+   * solr.hideStackTrace=true.
+   *
+   * @see #getTypedErrorInfo(Throwable, Logger)
+   */
+  public static int getErrorInfo(Throwable ex, NamedList<Object> info, Logger 
log, SolrCore core) {

Review Comment:
   could you replace 'core' instance with just the hideStackTrace flag? there 
is no reason to pass in the entire core.



##########
solr/core/src/java/org/apache/solr/servlet/ResponseUtils.java:
##########
@@ -135,4 +177,10 @@ public static ErrorInfo getTypedErrorInfo(Throwable ex, 
Logger log) {
     errorInfo.code = code;
     return errorInfo;
   }
+
+  private static boolean hideStackTrace(SolrCore core) {
+    return core != null
+        ? core.getCoreContainer().hideStackTrace()
+        : Boolean.parseBoolean(System.getProperty("solr.hideStackTrace"));

Review Comment:
   no need to check the system property value every time you need to log an 
error. you can move this to the init phase, in the NodeConfig maybe? and pass 
that value to the log method.



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