adarshsanjeev commented on code in PR #16708:
URL: https://github.com/apache/druid/pull/16708#discussion_r1689264688


##########
processing/src/main/java/org/apache/druid/error/DruidException.java:
##########
@@ -467,14 +470,27 @@ public DruidException build(String formatMe, Object... 
vals)
 
     public DruidException build(Throwable cause, String formatMe, Object... 
vals)
     {
-      return new DruidException(
+      final DruidException retVal = new DruidException(
           cause,
           errorCode,
           targetPersona,
           category,
           StringUtils.nonStrictFormat(formatMe, vals),
           deserialized
       );
+
+      StackTraceElement[] stackTrace = retVal.getStackTrace();
+      int firstNonDruidExceptionIndex = 0;
+      while (
+          firstNonDruidExceptionIndex < stackTrace.length &&
+          
stackTrace[firstNonDruidExceptionIndex].getClassName().startsWith(CLASS_NAME_STR))
 {
+        ++firstNonDruidExceptionIndex;
+      }
+      if (firstNonDruidExceptionIndex < stackTrace.length) {
+        retVal.setStackTrace(Arrays.copyOfRange(stackTrace, 
firstNonDruidExceptionIndex, stackTrace.length));

Review Comment:
   Changed this to `if (firstNonDruidExceptionIndex > 0)`
   
   If `firstNonDruidExceptionIndex == stackTrace.length`, we should copy an 
empty array, which is what would happen, and if the the exception is 0, we 
should not need a copy.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to