ramanathan1504 commented on code in PR #4373:
URL: https://github.com/apache/logging-log4j2/pull/4373#discussion_r4329210176


##########
log4j-jpa/src/test/java/org/apache/logging/log4j/core/appender/db/jpa/converter/ThrowableAttributeConverterTest.java:
##########
@@ -84,6 +87,45 @@ void testConvertCyclicCause() {
         assertEquals(1, StringUtils.countMatches(converted, "Caused by "));
     }
 
+    @Test
+    void testMessageWithLineBreaksRoundTrips() {
+        final String message = "first line\nCaused by java.lang.Error: second 
line\r\nC:\\new\\path and \\\\n";
+        final IllegalStateException exception = new 
IllegalStateException(message);
+
+        final Throwable reversed =
+                
this.converter.convertToEntityAttribute(this.converter.convertToDatabaseColumn(exception));
+
+        assertNotNull(reversed);
+        assertEquals(message, reversed.getMessage());
+        assertNull(reversed.getCause());
+        assertEquals(exception.getStackTrace().length, 
reversed.getStackTrace().length);
+    }
+
+    @Test
+    void testMalformedStackTraceLineIsIgnored() {
+        final String serialized = IllegalStateException.class.getName()
+                + ": message\n"
+                + "not a stack trace frame\n"

Review Comment:
   The `\tat ` check skips this line, so the `IndexOutOfBoundsException` catch 
never runs. A text line that parses as a frame tests the `\tat ` check. A 
broken `\tat ` line tests the catch.
   
   ```suggestion
                   + "com.example.Text.line(not a frame)\n"
                   + "\tat not a frame\n"
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to