>From Michael Blow <[email protected]>:
Michael Blow has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20390?usp=email )
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
---
M
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/90/20390/1
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: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: trinity
Gerrit-Change-Id: I97c2f2ae000c84681976bbf6cbc385f2ffa0ee54
Gerrit-Change-Number: 20390
Gerrit-PatchSet: 1
Gerrit-Owner: Michael Blow <[email protected]>