1616import java .util .regex .Pattern ;
1717
1818final class ErrorHelper {
19- private static final int MESSAGE_LENGTH = Math . min ( 1000 , Integer . getInteger ( "faststats.message-length" , 500 )) ;
20- private static final int STACK_TRACE_LENGTH = Math . min ( 500 , Integer . getInteger ( "faststats.stack-trace-length" , 300 )) ;
21- private static final int STACK_TRACE_LIMIT = Math . min ( 50 , Integer . getInteger ( "faststats.stack-trace-limit" , 15 )) ;
19+ public static final int MAX_MESSAGE_LENGTH = 1000 ;
20+ public static final int MAX_FRAME_SIZE = 300 ;
21+ public static final int MAX_STACK_SIZE = 30 ;
2222
2323 private static final Set <String > allowedNames = Set .of ("minecraft" , "server" , "root" , "ubuntu" );
2424 private static final List <Map .Entry <Pattern , String >> defaultAnonymizationEntries = defaultAnonymizationEntries ();
@@ -48,7 +48,7 @@ private static JsonObject compileAll(final TrackedError trackedError, @Nullable
4848 final var stack = collapseStackTrace (elements );
4949 final var list = new ArrayList <>(stack );
5050 if (suppress != null ) list .removeAll (suppress );
51- final var traces = Math .min (list .size (), STACK_TRACE_LIMIT );
51+ final var traces = Math .min (list .size (), MAX_STACK_SIZE );
5252
5353 populateTraces (traces , list , elements , stacktrace );
5454 appendCauseChain (error .getCause (), stack , suppress , stacktrace , customPatterns );
@@ -85,7 +85,7 @@ private static void appendCauseChain(@Nullable Throwable cause, final List<Strin
8585 final var causeStack = collapseStackTrace (causeElements );
8686 final var causeList = new ArrayList <>(causeStack );
8787 causeList .removeAll (toSuppress );
88- final var causeTraces = Math .min (causeList .size (), STACK_TRACE_LIMIT );
88+ final var causeTraces = Math .min (causeList .size (), MAX_STACK_SIZE );
8989 populateTraces (causeTraces , causeList , causeElements , stacktrace );
9090
9191 cause = cause .getCause ();
@@ -96,8 +96,8 @@ private static void populateTraces(final int traces, final List<String> list, fi
9696 final JsonArray stacktrace ) {
9797 for (var i = 0 ; i < traces ; i ++) {
9898 final var string = list .get (i );
99- if (string .length () <= STACK_TRACE_LENGTH ) stacktrace .add (" at " + string );
100- else stacktrace .add (" at " + string .substring (0 , STACK_TRACE_LENGTH ) + "..." );
99+ if (MAX_FRAME_SIZE < 0 || string .length () <= MAX_FRAME_SIZE ) stacktrace .add (" at " + string );
100+ else stacktrace .add (" at " + string .substring (0 , MAX_FRAME_SIZE ) + "..." );
101101 }
102102 if (traces > 0 && traces < list .size ()) {
103103 stacktrace .add (" ... " + (list .size () - traces ) + " more" );
@@ -216,8 +216,8 @@ private static boolean isSameClassLoader(final ClassLoader classLoader, final Cl
216216 private static @ Nullable String getAnonymizedMessage (final Throwable error , final List <Map .Entry <Pattern , String >> customPatterns ) {
217217 final var message = error .getMessage ();
218218 if (message == null ) return null ;
219- var truncated = message .length () > MESSAGE_LENGTH
220- ? message .substring (0 , MESSAGE_LENGTH ) + "..."
219+ var truncated = message .length () > MAX_MESSAGE_LENGTH
220+ ? message .substring (0 , MAX_MESSAGE_LENGTH ) + "..."
221221 : message ;
222222 for (final var entry : customPatterns ) {
223223 truncated = entry .getKey ().matcher (truncated ).replaceAll (entry .getValue ());
0 commit comments