You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "spuru9 (via GitHub)" <gi...@apache.org> on 2026/09/07 09:34:49 UTC
Re: [PR] [FLINK-40452] Cap exception fetching by size instead of line count [flink-kubernetes-operator]
spuru9 commented on code in PR #1194:
URL: https://github.com/apache/flink-kubernetes-operator/pull/1194#discussion_r3948405328
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/JobStatusObserver.java:
##########
@@ -267,15 +268,14 @@ private void emitJobManagerExceptionEvent(
StringBuilder eventMessage = new StringBuilder();
String stacktrace = exception.getStacktrace();
if (stacktrace != null && !stacktrace.isBlank()) {
- String[] lines = stacktrace.split("\n");
- for (int i = 0; i < Math.min(maxStackTraceLines, lines.length); i++) {
- eventMessage.append(lines[i]).append("\n");
- }
- if (lines.length > maxStackTraceLines) {
+ if (stacktrace.length() > maxStackTraceLength) {
eventMessage
+ .append(stacktrace, 0, maxStackTraceLength)
.append("... (")
- .append(lines.length - maxStackTraceLines)
- .append(" more lines)");
+ .append(stacktrace.length() - maxStackTraceLength)
+ .append(" more characters)");
+ } else {
+ eventMessage.append(stacktrace);
Review Comment:
nit optional: we can simply this to
```
if (stacktrace != null && !stacktrace.isBlank()) {
getSubstringWithMaxLength(stacktrace, maxStackTraceLength).ifPresent(eventMessage::append);
if (stacktrace.length() > maxStackTraceLength) {
eventMessage
.append("... (")
.append(stacktrace.length() - maxStackTraceLength)
.append(" more characters)");
}
}
```
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org