Skip to content

Commit e82419d

Browse files
sahasan95adinauer
andauthored
Replace deprecated ThrowableProxy with LogEvent#getThrown() in sentry-log4j2 (#5751)
* Replace deprecated ThrowableProxy with LogEvent#getThrown() in sentry-log4j2 * Add @nullable annotation and CHANGELOG entry --------- Co-authored-by: Alexander Dinauer <adinauer@users.noreply.github.com>
1 parent 5e269de commit e82419d

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- `SentryTagModifierNode.isImportantForBounds` now matches the default behavior and returns `true` ([#5789](https://github.com/getsentry/sentry-java/pull/5789))
1010
- Prevent a `StackOverflowError` when a `beforeSend`, `beforeBreadcrumb`, `beforeSendLog`, or `beforeEnvelope` callback triggers another capture (directly or through a logging integration such as Timber) ([#5737](https://github.com/getsentry/sentry-java/pull/5737))
1111
- Captures made from within a user callback (event, transaction, breadcrumb, log, envelope, or check-in) are now dropped while that callback runs, instead of recursing. Captures made by event processors are unaffected.
12+
- Replace deprecated `ThrowableProxy` with `LogEvent#getThrown()` in `sentry-log4j2` ([#5751](https://github.com/getsentry/sentry-java/pull/5751))
1213

1314
### Dependencies
1415

sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
4242
import org.apache.logging.log4j.core.config.plugins.PluginElement;
4343
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
44-
import org.apache.logging.log4j.core.impl.ThrowableProxy;
4544
import org.jetbrains.annotations.NotNull;
4645
import org.jetbrains.annotations.Nullable;
4746

@@ -274,13 +273,12 @@ protected void captureLog(@NotNull LogEvent loggingEvent) {
274273
event.setLogger(loggingEvent.getLoggerName());
275274
event.setLevel(formatLevel(loggingEvent.getLevel()));
276275

277-
final ThrowableProxy throwableInformation = loggingEvent.getThrownProxy();
278-
if (throwableInformation != null) {
276+
final @Nullable Throwable thrown = loggingEvent.getThrown();
277+
if (thrown != null) {
279278
final Mechanism mechanism = new Mechanism();
280279
mechanism.setType(MECHANISM_TYPE);
281280
final Throwable mechanismException =
282-
new ExceptionMechanismException(
283-
mechanism, throwableInformation.getThrowable(), Thread.currentThread());
281+
new ExceptionMechanismException(mechanism, thrown, Thread.currentThread());
284282
event.setThrowable(mechanismException);
285283
}
286284

0 commit comments

Comments
 (0)