Skip to content
Merged
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
6 changes: 6 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jacoco = "0.8.7"
jackson = "2.18.3"
jetbrainsCompose = "1.6.11"
kotlin = "1.9.24"
kotlinSpring7 = "2.2.0"
kotlin-compatible-version = "1.6"
ktorClient = "3.0.0"
logback = "1.2.9"
Expand Down Expand Up @@ -96,6 +97,7 @@ jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", ver
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" }
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
kotlin-test-junit-spring7 = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinSpring7" }
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorClient" }
Expand Down Expand Up @@ -162,6 +164,8 @@ springboot4-starter-websocket = { module = "org.springframework.boot:spring-boot
springboot4-starter-webflux = { module = "org.springframework.boot:spring-boot-starter-webflux", version.ref = "springboot4" }
springboot4-starter-aop = { module = "org.springframework.boot:spring-boot-starter-aop", version.ref = "springboot4" }
springboot4-starter-security = { module = "org.springframework.boot:spring-boot-starter-security", version.ref = "springboot4" }
springboot4-starter-restclient = { module = "org.springframework.boot:spring-boot-starter-restclient", version.ref = "springboot4" }
springboot4-starter-webclient = { module = "org.springframework.boot:spring-boot-starter-webclient", version.ref = "springboot4" }
springboot4-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "springboot4" }
springboot4-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "springboot4" }
timber = { module = "com.jakewharton.timber:timber", version = "4.7.1" }
Expand All @@ -177,12 +181,14 @@ androidx-test-orchestrator = { module = "androidx.test:orchestrator", version =
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidxTestCore" }
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
awaitility-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "4.1.1" }
awaitility-kotlin-spring7 = { module = "org.awaitility:awaitility-kotlin", version = "4.3.0" }
awaitility3-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "3.1.6" }
hsqldb = { module = "org.hsqldb:hsqldb", version = "2.6.1" }
javafaker = { module = "com.github.javafaker:javafaker", version = "1.0.2" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
leakcanary-instrumentation = { module = "com.squareup.leakcanary:leakcanary-android-instrumentation", version = "2.14" }
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "4.1.0" }
mockito-kotlin-spring7 = { module = "org.mockito.kotlin:mockito-kotlin", version = "6.0.0" }
mockito-inline = { module = "org.mockito:mockito-inline", version = "4.8.0" }
msgpack = { module = "org.msgpack:msgpack-core", version = "0.9.8" }
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
public final class io/sentry/spring/jakarta/BuildConfig {
public static final field SENTRY_SPRING_JAKARTA_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

public final class io/sentry/spring/jakarta/ContextTagsEventProcessor : io/sentry/EventProcessor {
public fun <init> (Lio/sentry/SentryOptions;)V
public fun getOrder ()Ljava/lang/Long;
Expand Down Expand Up @@ -124,10 +119,10 @@ public class io/sentry/spring/jakarta/checkin/SentryCheckInPointcutConfiguration

public class io/sentry/spring/jakarta/checkin/SentryQuartzConfiguration {
public fun <init> ()V
public fun schedulerFactoryBeanCustomizer ()Lorg/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer;
public fun schedulerFactoryBeanCustomizer ()Lorg/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer;
}

public final class io/sentry/spring/jakarta/checkin/SentrySchedulerFactoryBeanCustomizer : org/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer {
public final class io/sentry/spring/jakarta/checkin/SentrySchedulerFactoryBeanCustomizer : org/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer {
public fun <init> ()V
public fun customize (Lorg/springframework/scheduling/quartz/SchedulerFactoryBean;)V
}
Expand Down Expand Up @@ -361,3 +356,8 @@ public final class io/sentry/spring/jakarta/webflux/reactor/ReactorUtils : io/se
public fun <init> ()V
}

public final class io/sentry/spring7/BuildConfig {
public static final field SENTRY_SPRING_7_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

6 changes: 3 additions & 3 deletions sentry-spring-7/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ dependencies {
testImplementation(projects.sentryTestSupport)
testImplementation(projects.sentryGraphql)
testImplementation(kotlin(Config.kotlinStdLib))
testImplementation(libs.awaitility.kotlin)
testImplementation(libs.awaitility.kotlin.spring7)
testImplementation(libs.context.propagation)
testImplementation(libs.graphql.java24)
testImplementation(libs.kotlin.test.junit)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlin.test.junit.spring7)
testImplementation(libs.mockito.kotlin.spring7)
testImplementation(libs.mockito.inline)
testImplementation(libs.springboot4.starter.aop)
testImplementation(libs.springboot4.starter.graphql)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.sentry.SentryOptions;
import io.sentry.protocol.SdkVersion;
import io.sentry.spring.jakarta.tracing.SpringMvcTransactionNameProvider;
import io.sentry.spring7.BuildConfig;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
Expand Down Expand Up @@ -50,7 +51,7 @@ private void registerSentryOptions(
}
builder.addPropertyValue("dsn", annotationAttributes.getString("dsn"));
builder.addPropertyValue("enableExternalConfiguration", true);
builder.addPropertyValue("sentryClientName", BuildConfig.SENTRY_SPRING_JAKARTA_SDK_NAME);
builder.addPropertyValue("sentryClientName", BuildConfig.SENTRY_SPRING_7_SDK_NAME);
builder.addPropertyValue("sdkVersion", createSdkVersion());
builder.addPropertyValue("initPriority", InitPriority.LOW);
addPackageAndIntegrationInfo();
Expand Down Expand Up @@ -90,7 +91,7 @@ private void registerSentryExceptionResolver(
final SentryOptions defaultOptions = new SentryOptions();
SdkVersion sdkVersion = defaultOptions.getSdkVersion();

final String name = BuildConfig.SENTRY_SPRING_JAKARTA_SDK_NAME;
final String name = BuildConfig.SENTRY_SPRING_7_SDK_NAME;
final String version = BuildConfig.VERSION_NAME;
sdkVersion = SdkVersion.updateSdkVersion(sdkVersion, name, version);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void configureScope(
final @NotNull IScopes scopes, final @NotNull HttpServletRequest request) {
if (scopes.getOptions().isSendDefaultPii()
&& qualifiesForCaching(request, scopes.getOptions().getMaxRequestBodySize())) {
return new ContentCachingRequestWrapper(request);
return new ContentCachingRequestWrapper(request, 0);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Request Body Caching Limit Set Incorrectly

The ContentCachingRequestWrapper constructor now hardcodes 0 as the cache limit. This likely disables or severely restricts request body caching, overriding the intended behavior determined by qualifiesForCaching and the maxRequestBodySize configuration (e.g., 1000 bytes for SMALL, 10000 for MEDIUM).

Fix in Cursor Fix in Web

}
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.jakewharton.nopen.annotation.Open;
import org.jetbrains.annotations.ApiStatus;
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
import org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.sentry.quartz.SentryJobListener;
import org.jetbrains.annotations.ApiStatus;
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
import org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

@ApiStatus.Experimental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public SentryRequestResolver(final @NotNull IScopes scopes) {
@NotNull
Map<String, String> resolveHeadersMap(final HttpHeaders request) {
final Map<String, String> headersMap = new HashMap<>();
for (Map.Entry<String, List<String>> entry : request.entrySet()) {
for (Map.Entry<String, List<String>> entry : request.headerSet()) {
// do not copy personal information identifiable headers
String headerName = entry.getKey();
if (scopes.getOptions().isSendDefaultPii()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.sentry.ITransportFactory
import io.sentry.Integration
import io.sentry.Sentry
import io.sentry.SentryOptions
import io.sentry.spring7.BuildConfig
import io.sentry.transport.ITransport
import kotlin.test.Test
import org.assertj.core.api.Assertions.assertThat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import org.mockito.kotlin.whenever
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.client.TestRestTemplate
import org.springframework.boot.test.web.server.LocalServerPort
import org.springframework.boot.web.server.test.LocalServerPort
import org.springframework.boot.web.server.test.client.TestRestTemplate
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
Expand Down Expand Up @@ -110,7 +110,7 @@ class SentrySpringIntegrationTest {
fun `attaches request and user information to SentryEvents`() {
val restTemplate = TestRestTemplate().withBasicAuth("user", "password")
val headers = HttpHeaders()
headers["X-FORWARDED-FOR"] = listOf("169.128.0.1")
headers.put("X-FORWARDED-FOR", listOf("169.128.0.1"))
val entity = HttpEntity<Void>(headers)

restTemplate.exchange("http://localhost:$port/hello", HttpMethod.GET, entity, Void::class.java)
Expand Down Expand Up @@ -176,7 +176,7 @@ class SentrySpringIntegrationTest {
fun `attaches first ip address if multiple addresses exist in a header`() {
val restTemplate = TestRestTemplate().withBasicAuth("user", "password")
val headers = HttpHeaders()
headers["X-FORWARDED-FOR"] = listOf("169.128.0.1, 192.168.0.1")
headers.put("X-FORWARDED-FOR", listOf("169.128.0.1, 192.168.0.1"))
val entity = HttpEntity<Void>(headers)

restTemplate.exchange("http://localhost:$port/hello", HttpMethod.GET, entity, Void::class.java)
Expand Down Expand Up @@ -530,7 +530,10 @@ open class SecurityConfiguration {
@Bean
@Throws(Exception::class)
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic()
http
.csrf { it.disable() }
.authorizeHttpRequests { it.anyRequest().authenticated() }
.httpBasic {}

return http.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import org.mockito.kotlin.whenever
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.ApplicationRunner
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
import org.springframework.boot.security.autoconfigure.reactive.ReactiveSecurityAutoConfiguration
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.boot.test.web.server.LocalServerPort
import org.springframework.boot.web.server.test.LocalServerPort
import org.springframework.context.annotation.Bean
import org.springframework.http.ResponseEntity
import org.springframework.test.context.junit4.SpringRunner
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
public final class io/sentry/spring/boot/jakarta/BuildConfig {
public static final field SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

public class io/sentry/spring/boot/jakarta/InAppIncludesResolver : org/springframework/context/ApplicationContextAware {
public fun <init> ()V
public fun resolveInAppIncludes ()Ljava/util/List;
Expand Down Expand Up @@ -91,3 +86,8 @@ public class io/sentry/spring/boot/jakarta/graphql/SentryGraphqlAutoConfiguratio
public fun sentryInstrumentationWebflux (Lio/sentry/spring/boot/jakarta/SentryProperties;Lorg/springframework/beans/factory/ObjectProvider;)Lio/sentry/graphql/SentryInstrumentation;
}

public final class io/sentry/spring/boot4/BuildConfig {
public static final field SENTRY_SPRING_BOOT_4_SDK_NAME Ljava/lang/String;
public static final field VERSION_NAME Ljava/lang/String;
}

2 changes: 2 additions & 0 deletions sentry-spring-boot-4/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ dependencies {
compileOnly(libs.springboot4.starter.graphql)
compileOnly(libs.springboot4.starter.quartz)
compileOnly(libs.springboot4.starter.security)
compileOnly(libs.springboot4.starter.restclient)
compileOnly(libs.springboot4.starter.webclient)
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryCore)
compileOnly(projects.sentryOpentelemetry.sentryOpentelemetryAgentcustomization)
api(projects.sentryReactor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.sentry.quartz.SentryJobListener;
import io.sentry.spring.boot.jakarta.graphql.SentryGraphql22AutoConfiguration;
import io.sentry.spring.boot.jakarta.graphql.SentryGraphqlAutoConfiguration;
import io.sentry.spring.boot4.BuildConfig;
import io.sentry.spring.jakarta.ContextTagsEventProcessor;
import io.sentry.spring.jakarta.SentryExceptionResolver;
import io.sentry.spring.jakarta.SentryRequestResolver;
Expand Down Expand Up @@ -59,12 +60,12 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.info.GitProperties;
import org.springframework.boot.restclient.autoconfigure.RestClientAutoConfiguration;
import org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.webclient.autoconfigure.WebClientAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -167,7 +168,7 @@ static class OpenTelemetryNoAgentConfiguration {}
spanFactory.ifAvailable(options::setSpanFactory);

options.setSentryClientName(
BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
BuildConfig.SENTRY_SPRING_BOOT_4_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
options.setSdkVersion(createSdkVersion(options));
options.setInitPriority(InitPriority.LOW);
addPackageAndIntegrationInfo();
Expand Down Expand Up @@ -461,7 +462,7 @@ static class ApacheHttpClientTransportFactoryAutoconfiguration {
final @NotNull SentryOptions sentryOptions) {
SdkVersion sdkVersion = sentryOptions.getSdkVersion();

final String name = BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME;
final String name = BuildConfig.SENTRY_SPRING_BOOT_4_SDK_NAME;
final String version = BuildConfig.VERSION_NAME;
sdkVersion = SdkVersion.updateSdkVersion(sdkVersion, name, version);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.sentry.IScopes;
import io.sentry.spring.jakarta.tracing.SentrySpanClientHttpRequestInterceptor;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.web.client.RestClientCustomizer;
import org.springframework.boot.restclient.RestClientCustomizer;
import org.springframework.web.client.RestClient;

@Open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.boot.restclient.RestTemplateCustomizer;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.sentry.IScopes;
import io.sentry.spring.jakarta.tracing.SentrySpanClientWebRequestFilter;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.boot.webclient.WebClientCustomizer;
import org.springframework.web.reactive.function.client.WebClient;

@Open
Expand Down
Loading