Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/transforms/detect_exceptions/exception_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ mod exception_detector_tests {
check_exception(java_simple_exception(), false);
check_exception(java_complex_exception(), false);
check_exception(java_nested_exception(), false);
check_exception(java_exception_with_non_nested_lines(), false);
}

const fn java_simple_exception() -> &'static str {
Expand Down Expand Up @@ -339,6 +340,16 @@ Caused by: com.example.myproject.MyProjectServletException
"
}

const fn java_exception_with_non_nested_lines() -> &'static str {
"
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12521, TNS:listener does not currently know of instance requested in connect descriptor
(CONNECTION_ID=r6n2ZPL0TqS/BLDhIydj+A==)
at oracle.jdbc.driver.T4CConnection.handleLogonNetException(T4CConnection.java:893)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:698)
"
}

const fn java_nested_exception() -> &'static str {
"
java.lang.RuntimeException: javax.mail.SendFailedException: Invalid Addresses;
Expand Down Expand Up @@ -366,6 +377,8 @@ com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[REDACTED_EMAIL_ADDRESS
at com.nethunt.crm.api.server.adminsync.AutomaticEmailFacade.sendWithSmtp(AutomaticEmailFacade.java:229)
... 12 more
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 <[REDACTED_EMAIL_ADDRESS]>... Relaying denied
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:2064)
... 12 more
"
}

Expand Down
51 changes: 51 additions & 0 deletions src/transforms/detect_exceptions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,55 @@ Jul 09, 2015 3:23:29 PM com.google.devtools.search.cloud.feeder.MakeLog: Runtime
assert_eq!(output_2["message"], java_simple_log.trim().into());
assert_eq!(output_2["counter"], Value::from(6));
}

#[tokio::test]
async fn test_exception_with_non_nested_continuation_lines() {
let detect_exceptions = toml::from_str::<DetectExceptionsConfig>(
r#"
languages = ["Java"]
"#,
)
.unwrap()
.build(&TransformContext::default())
.await
.unwrap();

let detect_exceptions = detect_exceptions.into_task();

let exception_with_continuation = "\
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12521, TNS:listener does not currently know of instance requested in connect descriptor
(CONNECTION_ID=r6n2ZPL0TqS/BLDhIydj+A==)
at oracle.jdbc.driver.T4CConnection.handleLogonNetException(T4CConnection.java:893)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:698)";
let regular_log = "2026-06-02 13:55:59.506 INFO normal log message";

let lines = format!("{}\n{}", exception_with_continuation, regular_log);

let mut counter = 0;
let input_events: Vec<Event> = lines
.split("\n")
.map(|line| {
let mut le = LogEvent::from(line);
le.insert("counter", counter);
counter += 1;
Event::Log(le)
})
.collect();

let in_stream = Box::pin(stream::iter(input_events));
let mut out_stream = detect_exceptions.transform_events(in_stream);

let output_1 = out_stream.next().await.unwrap().into_log();
assert_eq!(
output_1["message"],
exception_with_continuation.into(),
"All exception lines including non-nested continuations must be merged into one event"
);
assert_eq!(output_1["counter"], Value::from(0));

let output_2 = out_stream.next().await.unwrap().into_log();
assert_eq!(output_2["message"], regular_log.into());
assert_eq!(output_2["counter"], Value::from(5));
}
}
3 changes: 3 additions & 0 deletions src/transforms/detect_exceptions/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ fn java_rules() -> Vec<Rule<'static>> {
r"^[\t ]*... \d+ (?:more|common frames omitted)",
Java,
),
// Catch-all for non-indented continuation lines between the exception
// header and the stack trace (e.g. multi-line error messages).
rule(vec![JavaAfterException], r"^.+$", JavaAfterException),
]
}

Expand Down