This is an automated email from the ASF dual-hosted git repository.

imaxon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit 015a3bca28f996e5ba70eb42db8aa765e14d3cc7
Merge: d22fc3f8c4 99fa79cd50
Author: Michael Blow <[email protected]>
AuthorDate: Thu Oct 2 09:30:13 2025 -0400

    Merge branch 'gerrit/trinity' into 'gerrit/phoenix'
    
     * [NO ISSUE][HYR][STO] Update FileMapManager serialVersionUID
     * [NO ISSUE][*DB] += valid tx check, allow active setRunning to throw
     * [NO ISSUE][HYR][MISC] Add utility method to abbreviate a stack
       overflow error
    
    Ext-ref: MB-68720,MB-68587
    Change-Id: I0ec0f3f3203af1c0844bf07875c55dd154b3b542

 .../org/apache/hyracks/api/util/ExceptionUtils.java    | 18 ++++++++++++++++++
 .../hyracks/storage/common/file/FileMapManager.java    |  4 +---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --cc 
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ExceptionUtils.java
index 8e182fb64a,30c02382dd..81de6ed72c
--- 
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
@@@ -238,28 -237,21 +238,46 @@@ public class ExceptionUtils 
          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;
+     }
++
 +    /**
 +     * Checks if the specific type T exception is in the causes of the 
current throwable, and if so returns it,
 +     * otherwise returns null
 +     *
 +     * @param throwable throwable
 +     * @param targetType exception being targeted
 +     * @return targetType exception if found, null otherwise
 +     * @param <T> type of exception being targeted
 +     */
 +    public static <T extends Throwable> Optional<T> getCauseOfType(Throwable 
throwable, Class<T> targetType) {
 +        if (throwable == null || targetType == null) {
 +            return Optional.empty();
 +        }
 +
 +        Throwable cause = throwable;
 +        while (cause != null) {
 +            if (targetType.isInstance(cause)) {
 +                return Optional.of(targetType.cast(cause));
 +            }
 +            cause = cause.getCause();
 +        }
 +
 +        return Optional.empty();
 +    }
  }

Reply via email to