Skip to content

Commit

Permalink
Do not register sentrySpringFilter in ServletContext for Spring Boot (
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer authored Nov 6, 2023
1 parent 3d8bd2b commit 2fad834
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Do not register `sentrySpringFilter` in ServletContext for Spring Boot ([#3027](https://github.com/getsentry/sentry-java/pull/3027))

## 6.33.0

### Features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.sentry.spring.jakarta;

import static io.sentry.util.ClassLoaderUtils.classLoaderOrDefault;

import com.jakewharton.nopen.annotation.Open;
import jakarta.servlet.DispatcherType;
import jakarta.servlet.FilterRegistration;
Expand All @@ -20,10 +22,17 @@ public class SentrySpringServletContainerInitializer implements ServletContainer
@Override
public void onStartup(final @Nullable Set<Class<?>> c, final @NotNull ServletContext ctx)
throws ServletException {
final FilterRegistration.Dynamic dynamic =
ctx.addFilter("sentrySpringFilter", SentrySpringFilter.class);
if (dynamic != null) {
dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
try {
Class.forName(
"org.springframework.boot.SpringApplication",
false,
classLoaderOrDefault(getClass().getClassLoader()));
} catch (ClassNotFoundException e) {
final FilterRegistration.Dynamic dynamic =
ctx.addFilter("sentrySpringFilter", SentrySpringFilter.class);
if (dynamic != null) {
dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
}
}
}
}

0 comments on commit 2fad834

Please sign in to comment.