>From Michael Blow <[email protected]>:

Michael Blow has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20390?usp=email )

 (

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
 )Change subject: [NO ISSUE][HYR][MISC] Add utility method to abbreviate a 
stack overflow error
......................................................................

[NO ISSUE][HYR][MISC] Add utility method to abbreviate a stack overflow error

Ext-ref: MB-68587
Change-Id: I97c2f2ae000c84681976bbf6cbc385f2ffa0ee54
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20390
Reviewed-by: Ian Maxon <[email protected]>
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
---
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
1 file changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Jenkins: Verified; Verified
  Ian Maxon: Looks good to me, approved




diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
index a0863b2..30c0238 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
@@ -236,4 +236,22 @@
     public static boolean isErrorCode(HyracksDataException throwable, 
ErrorCode code) {
         return throwable.getError().isPresent() && throwable.getError().get() 
== code;
     }
+
+    public static Throwable truncateStackOverflowStack(Throwable ex, int 
limit) {
+        if (ex instanceof StackOverflowError) {
+            StackTraceElement[] fullTrace = ex.getStackTrace();
+            if (fullTrace.length > limit * 2) {
+                StackOverflowError copy = new 
StackOverflowError(ex.getMessage());
+                // keep the cause if there was one
+                copy.initCause(ex.getCause());
+                StackTraceElement[] trimmedTrace = new StackTraceElement[limit 
+ 1];
+                System.arraycopy(fullTrace, 0, trimmedTrace, 0, limit);
+                trimmedTrace[limit] = new StackTraceElement("...<truncated " + 
(fullTrace.length - limit) + " lines>",
+                        "..", null, -1);
+                copy.setStackTrace(trimmedTrace);
+                return copy;
+            }
+        }
+        return ex;
+    }
 }

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20390?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: asterixdb
Gerrit-Branch: trinity
Gerrit-Change-Id: I97c2f2ae000c84681976bbf6cbc385f2ffa0ee54
Gerrit-Change-Number: 20390
Gerrit-PatchSet: 3
Gerrit-Owner: Michael Blow <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Ian Maxon <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Michael Blow <[email protected]>

Reply via email to