-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9631] Limit length of errorMessage for better stability
- Loading branch information
Showing
9 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../com/navercorp/pinpoint/profiler/context/exception/model/ExceptionWrapperFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.navercorp.pinpoint.profiler.context.exception.model; | ||
|
||
|
||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author intr3p1d | ||
*/ | ||
class ExceptionWrapperFactoryTest { | ||
|
||
private final static int MAX_DEPTH = 5; | ||
private final static int MAX_LENGTH = 10; | ||
private final static int ANY_INT = 1; | ||
ExceptionWrapperFactory factory = new ExceptionWrapperFactory(MAX_DEPTH, MAX_LENGTH); | ||
|
||
@Test | ||
public void testErrorMessageLimitWorks() { | ||
String errorMessage = "Message that exceed 10 characters"; | ||
Throwable th = new RuntimeException(errorMessage); | ||
|
||
List<ExceptionWrapper> wrappers = factory.newExceptionWrappers(th, ANY_INT, ANY_INT); | ||
|
||
String abbreviated = StringUtils.abbreviate(errorMessage, MAX_LENGTH); | ||
Assertions.assertEquals(abbreviated, wrappers.get(0).getExceptionMessage()); | ||
Assertions.assertEquals(abbreviated.length(), wrappers.get(0).getExceptionMessage().length()); | ||
} | ||
|
||
@Test | ||
public void testExceptionMaxDepthWorks(){ | ||
Throwable th = new RuntimeException("inital throwable"); | ||
for (int i = 0; i < 10; i++) { | ||
th = new RuntimeException(th); | ||
} | ||
|
||
List<ExceptionWrapper> wrappers = factory.newExceptionWrappers(th, ANY_INT, ANY_INT); | ||
Assertions.assertEquals(MAX_DEPTH, wrappers.size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters