Skip to content

Commit eacc1cc

Browse files
committed
[GR-70603] Allow ProgressReporterUtils#truncateFQN(String, int) to truncate further
PullRequest: graal/22321
2 parents c9a8a5a + 0a30c32 commit eacc1cc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterUtils.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525

2626
package com.oracle.svm.hosted;
2727

28-
import com.oracle.svm.core.util.ByteFormattingUtil;
29-
3028
import java.net.URL;
3129
import java.security.CodeSource;
3230

31+
import com.oracle.svm.core.util.ByteFormattingUtil;
32+
3333
final class ProgressReporterUtils {
3434

3535
private static final double MILLIS_TO_SECONDS = 1000d;
@@ -85,12 +85,22 @@ static String truncateFQN(String fqn, int maxLength) {
8585
}
8686
break;
8787
}
88+
if (sb.length() + 2 >= maxLength) {
89+
// if next char + '.' reaches limit, stop
90+
sb.append(TRUNCATION_PLACEHOLDER);
91+
break;
92+
}
8893
sb.append(fqn.charAt(currentDot + 1)).append('.');
8994
if (sb.length() + (classNameLength - nextDot) <= maxLength) {
9095
// Rest fits maxLength, append and return.
9196
sb.append(fqn.substring(nextDot + 1));
9297
break;
9398
}
99+
if (sb.length() + 1 >= maxLength) {
100+
// if no more space for next reduction, stop
101+
sb.append(TRUNCATION_PLACEHOLDER);
102+
break;
103+
}
94104
currentDot = nextDot;
95105
}
96106
return sb.toString();

0 commit comments

Comments
 (0)