Skip to content

Commit 9f8af82

Browse files
committed
update naming and add final
1 parent 7d7c559 commit 9f8af82

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public ThrowableProxy getCauseProxy() {
255255
* @param suffix Append this to the end of each stack frame.
256256
*/
257257
public String getCauseStackTraceAsString(final String suffix) {
258-
return this.getCauseStackTraceAsString(null, PlainTextRenderer.getInstance(), suffix, EOL_STR, null);
258+
return this.getCauseStackTraceAsString(null, PlainTextRenderer.getInstance(), suffix, EOL_STR);
259259
}
260260

261261
/**
@@ -266,7 +266,7 @@ public String getCauseStackTraceAsString(final String suffix) {
266266
* @return The formatted Throwable that caused this Throwable.
267267
*/
268268
public String getCauseStackTraceAsString(final List<String> packages, final String suffix) {
269-
return getCauseStackTraceAsString(packages, PlainTextRenderer.getInstance(), suffix, EOL_STR, null);
269+
return getCauseStackTraceAsString(packages, PlainTextRenderer.getInstance(), suffix, EOL_STR);
270270
}
271271

272272
/**
@@ -279,7 +279,7 @@ public String getCauseStackTraceAsString(final List<String> packages, final Stri
279279
*/
280280
public String getCauseStackTraceAsString(
281281
final List<String> ignorePackages, final TextRenderer textRenderer, final String suffix) {
282-
return getCauseStackTraceAsString(ignorePackages, textRenderer, suffix, EOL_STR, null);
282+
return getCauseStackTraceAsString(ignorePackages, textRenderer, suffix, EOL_STR);
283283
}
284284

285285
/**
@@ -295,11 +295,10 @@ public String getCauseStackTraceAsString(
295295
final List<String> ignorePackages,
296296
final TextRenderer textRenderer,
297297
final String suffix,
298-
final String lineSeparator,
299-
final Integer linesToKeep) {
298+
final String lineSeparator) {
300299
final StringBuilder sb = new StringBuilder();
301300
ThrowableProxyRenderer.formatCauseStackTraceTo(
302-
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, linesToKeep);
301+
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, null);
303302
return sb.toString();
304303
}
305304

@@ -311,17 +310,17 @@ public String getCauseStackTraceAsString(
311310
* @param textRenderer The message renderer.
312311
* @param suffix Append this to the end of each stack frame.
313312
* @param lineSeparator The end-of-line separator.
314-
* @param linesToKeep The total line count of final result
313+
* @param maxLineCount The total line count of final result
315314
*/
316315
public void formatCauseStackTraceTo(
317316
final StringBuilder sb,
318317
final List<String> ignorePackages,
319318
final TextRenderer textRenderer,
320319
final String suffix,
321320
final String lineSeparator,
322-
final Integer linesToKeep) {
321+
final Integer maxLineCount) {
323322
ThrowableProxyRenderer.formatCauseStackTraceTo(
324-
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, linesToKeep);
323+
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, maxLineCount);
325324
}
326325

327326
/**
@@ -424,17 +423,17 @@ public String getExtendedStackTraceAsString(
424423
* @param textRenderer The message renderer.
425424
* @param suffix Append this to the end of each stack frame.
426425
* @param lineSeparator The end-of-line separator.
427-
* @param linesToKeep The total line count of final result
426+
* @param maxLineCount The total line count of final result
428427
*/
429428
public void formatExtendedStackTraceTo(
430429
final StringBuilder sb,
431430
final List<String> ignorePackages,
432431
final TextRenderer textRenderer,
433432
final String suffix,
434433
final String lineSeparator,
435-
final Integer linesToKeep) {
434+
final Integer maxLineCount) {
436435
ThrowableProxyRenderer.formatExtendedStackTraceTo(
437-
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, linesToKeep);
436+
this, sb, ignorePackages, textRenderer, suffix, lineSeparator, maxLineCount);
438437
}
439438

440439
public String getLocalizedMessage() {

log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxyRenderer.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void formatExtendedStackTraceTo(
241241
final TextRenderer textRenderer,
242242
final String suffix,
243243
final String lineSeparator,
244-
final Integer linesToKeep) {
244+
final Integer maxLineCount) {
245245
renderOn(src, sb, textRenderer);
246246
renderSuffix(suffix, sb, textRenderer);
247247
textRenderer.render(lineSeparator, sb, "Text");
@@ -259,7 +259,7 @@ static void formatExtendedStackTraceTo(
259259
lineSeparator);
260260
formatSuppressed(sb, TAB, src.getSuppressedProxies(), ignorePackages, textRenderer, suffix, lineSeparator);
261261
formatCause(sb, Strings.EMPTY, src.getCauseProxy(), ignorePackages, textRenderer, suffix, lineSeparator);
262-
truncateLines(sb, lineSeparator, linesToKeep, textRenderer);
262+
truncateLines(sb, lineSeparator, maxLineCount, textRenderer);
263263
}
264264

265265
/**
@@ -279,7 +279,7 @@ static void formatCauseStackTraceTo(
279279
final TextRenderer textRenderer,
280280
final String suffix,
281281
final String lineSeparator,
282-
final Integer linesToKeep) {
282+
final Integer maxLineCount) {
283283
final ThrowableProxy causeProxy = src.getCauseProxy();
284284
if (causeProxy != null) {
285285
formatWrapper(sb, causeProxy, ignorePackages, textRenderer, suffix, lineSeparator);
@@ -299,7 +299,7 @@ static void formatCauseStackTraceTo(
299299
textRenderer,
300300
suffix,
301301
lineSeparator);
302-
truncateLines(sb, lineSeparator, linesToKeep, textRenderer);
302+
truncateLines(sb, lineSeparator, maxLineCount, textRenderer);
303303
}
304304

305305
private static void renderOn(
@@ -313,20 +313,23 @@ private static void renderOn(
313313
}
314314

315315
private static void truncateLines(
316-
StringBuilder sb, String lineSeparator, Integer linesToKeep, TextRenderer textRenderer) {
317-
if (linesToKeep == null) {
316+
final StringBuilder sb,
317+
final String lineSeparator,
318+
final Integer maxLineCount,
319+
final TextRenderer textRenderer) {
320+
if (maxLineCount == null) {
318321
return;
319322
}
320323

321324
String content = sb.toString();
322325
String[] lines = content.split(lineSeparator);
323326

324-
if (lines.length <= linesToKeep) {
327+
if (lines.length <= maxLineCount) {
325328
return;
326329
}
327330

328331
sb.setLength(0);
329-
for (int i = 0; i < linesToKeep; i++) {
332+
for (int i = 0; i < maxLineCount; i++) {
330333
sb.append(lines[i]);
331334
textRenderer.render(lineSeparator, sb, "Text");
332335
}

log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowablePatternConverter.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,27 +275,32 @@ private void appendEntry(
275275
sb.append(lineSeparator);
276276
}
277277

278-
private void appendSuffix(StringBuilder buffer, String suffix) {
278+
private void appendSuffix(
279+
final StringBuilder buffer,
280+
final String suffix) {
279281
if (Strings.isNotBlank(suffix)) {
280282
buffer.append(' ');
281283
buffer.append(suffix);
282284
}
283285
}
284286

285-
private void truncateLines(StringBuilder sb, String lineSeparator, Integer linesToKeep) {
286-
if (linesToKeep == null) {
287+
private void truncateLines(
288+
final StringBuilder sb,
289+
final String lineSeparator,
290+
final Integer maxLineCount) {
291+
if (maxLineCount == null) {
287292
return;
288293
}
289294

290295
String content = sb.toString();
291296
String[] lines = content.split(lineSeparator);
292297

293-
if (lines.length <= linesToKeep) {
298+
if (lines.length <= maxLineCount) {
294299
return;
295300
}
296301

297302
sb.setLength(0);
298-
for (int i = 0; i < linesToKeep; i++) {
303+
for (int i = 0; i < maxLineCount; i++) {
299304
sb.append(lines[i]);
300305
sb.append(lineSeparator);
301306
}

0 commit comments

Comments
 (0)