Skip to content

Commit c7988b5

Browse files
committed
Fix Spring 7 and Spring Boot 4 modules
1 parent 9899937 commit c7988b5

18 files changed

+51
-37
lines changed

gradle/libs.versions.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jacoco = "0.8.7"
1212
jackson = "2.18.3"
1313
jetbrainsCompose = "1.6.11"
1414
kotlin = "1.9.24"
15+
kotlinSpring7 = "2.2.0"
1516
kotlin-compatible-version = "1.6"
1617
ktorClient = "3.0.0"
1718
logback = "1.2.9"
@@ -96,6 +97,7 @@ jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", ver
9697
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
9798
jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" }
9899
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlin" }
100+
kotlin-test-junit-spring7 = { module = "org.jetbrains.kotlin:kotlin-test-junit", version.ref = "kotlinSpring7" }
99101
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
100102
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }
101103
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktorClient" }
@@ -162,6 +164,8 @@ springboot4-starter-websocket = { module = "org.springframework.boot:spring-boot
162164
springboot4-starter-webflux = { module = "org.springframework.boot:spring-boot-starter-webflux", version.ref = "springboot4" }
163165
springboot4-starter-aop = { module = "org.springframework.boot:spring-boot-starter-aop", version.ref = "springboot4" }
164166
springboot4-starter-security = { module = "org.springframework.boot:spring-boot-starter-security", version.ref = "springboot4" }
167+
springboot4-starter-restclient = { module = "org.springframework.boot:spring-boot-starter-restclient", version.ref = "springboot4" }
168+
springboot4-starter-webclient = { module = "org.springframework.boot:spring-boot-starter-webclient", version.ref = "springboot4" }
165169
springboot4-starter-jdbc = { module = "org.springframework.boot:spring-boot-starter-jdbc", version.ref = "springboot4" }
166170
springboot4-starter-actuator = { module = "org.springframework.boot:spring-boot-starter-actuator", version.ref = "springboot4" }
167171
timber = { module = "com.jakewharton.timber:timber", version = "4.7.1" }
@@ -177,12 +181,14 @@ androidx-test-orchestrator = { module = "androidx.test:orchestrator", version =
177181
androidx-test-rules = { module = "androidx.test:rules", version.ref = "androidxTestCore" }
178182
androidx-test-runner = { module = "androidx.test:runner", version = "1.6.2" }
179183
awaitility-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "4.1.1" }
184+
awaitility-kotlin-spring7 = { module = "org.awaitility:awaitility-kotlin", version = "4.3.0" }
180185
awaitility3-kotlin = { module = "org.awaitility:awaitility-kotlin", version = "3.1.6" }
181186
hsqldb = { module = "org.hsqldb:hsqldb", version = "2.6.1" }
182187
javafaker = { module = "com.github.javafaker:javafaker", version = "1.0.2" }
183188
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
184189
leakcanary-instrumentation = { module = "com.squareup.leakcanary:leakcanary-android-instrumentation", version = "2.14" }
185190
mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version = "4.1.0" }
191+
mockito-kotlin-spring7 = { module = "org.mockito.kotlin:mockito-kotlin", version = "6.0.0" }
186192
mockito-inline = { module = "org.mockito:mockito-inline", version = "4.8.0" }
187193
msgpack = { module = "org.msgpack:msgpack-core", version = "0.9.8" }
188194
okhttp-mockwebserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "okhttp" }

sentry-spring-7/api/sentry-spring-jakarta.api renamed to sentry-spring-7/api/sentry-spring-7.api

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
public final class io/sentry/spring/jakarta/BuildConfig {
2-
public static final field SENTRY_SPRING_JAKARTA_SDK_NAME Ljava/lang/String;
3-
public static final field VERSION_NAME Ljava/lang/String;
4-
}
5-
61
public final class io/sentry/spring/jakarta/ContextTagsEventProcessor : io/sentry/EventProcessor {
72
public fun <init> (Lio/sentry/SentryOptions;)V
83
public fun getOrder ()Ljava/lang/Long;
@@ -124,10 +119,10 @@ public class io/sentry/spring/jakarta/checkin/SentryCheckInPointcutConfiguration
124119

125120
public class io/sentry/spring/jakarta/checkin/SentryQuartzConfiguration {
126121
public fun <init> ()V
127-
public fun schedulerFactoryBeanCustomizer ()Lorg/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer;
122+
public fun schedulerFactoryBeanCustomizer ()Lorg/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer;
128123
}
129124

130-
public final class io/sentry/spring/jakarta/checkin/SentrySchedulerFactoryBeanCustomizer : org/springframework/boot/autoconfigure/quartz/SchedulerFactoryBeanCustomizer {
125+
public final class io/sentry/spring/jakarta/checkin/SentrySchedulerFactoryBeanCustomizer : org/springframework/boot/quartz/autoconfigure/SchedulerFactoryBeanCustomizer {
131126
public fun <init> ()V
132127
public fun customize (Lorg/springframework/scheduling/quartz/SchedulerFactoryBean;)V
133128
}
@@ -361,3 +356,8 @@ public final class io/sentry/spring/jakarta/webflux/reactor/ReactorUtils : io/se
361356
public fun <init> ()V
362357
}
363358

359+
public final class io/sentry/spring7/BuildConfig {
360+
public static final field SENTRY_SPRING_7_SDK_NAME Ljava/lang/String;
361+
public static final field VERSION_NAME Ljava/lang/String;
362+
}
363+

sentry-spring-7/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ dependencies {
5858
testImplementation(projects.sentryTestSupport)
5959
testImplementation(projects.sentryGraphql)
6060
testImplementation(kotlin(Config.kotlinStdLib))
61-
testImplementation(libs.awaitility.kotlin)
61+
testImplementation(libs.awaitility.kotlin.spring7)
6262
testImplementation(libs.context.propagation)
6363
testImplementation(libs.graphql.java24)
64-
testImplementation(libs.kotlin.test.junit)
65-
testImplementation(libs.mockito.kotlin)
64+
testImplementation(libs.kotlin.test.junit.spring7)
65+
testImplementation(libs.mockito.kotlin.spring7)
6666
testImplementation(libs.mockito.inline)
6767
testImplementation(libs.springboot4.starter.aop)
6868
testImplementation(libs.springboot4.starter.graphql)

sentry-spring-7/src/main/java/io/sentry/spring/jakarta/SentryHubRegistrar.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.sentry.SentryOptions;
88
import io.sentry.protocol.SdkVersion;
99
import io.sentry.spring.jakarta.tracing.SpringMvcTransactionNameProvider;
10+
import io.sentry.spring7.BuildConfig;
1011
import org.jetbrains.annotations.NotNull;
1112
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
1213
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
@@ -50,7 +51,7 @@ private void registerSentryOptions(
5051
}
5152
builder.addPropertyValue("dsn", annotationAttributes.getString("dsn"));
5253
builder.addPropertyValue("enableExternalConfiguration", true);
53-
builder.addPropertyValue("sentryClientName", BuildConfig.SENTRY_SPRING_JAKARTA_SDK_NAME);
54+
builder.addPropertyValue("sentryClientName", BuildConfig.SENTRY_SPRING_7_SDK_NAME);
5455
builder.addPropertyValue("sdkVersion", createSdkVersion());
5556
builder.addPropertyValue("initPriority", InitPriority.LOW);
5657
addPackageAndIntegrationInfo();
@@ -90,7 +91,7 @@ private void registerSentryExceptionResolver(
9091
final SentryOptions defaultOptions = new SentryOptions();
9192
SdkVersion sdkVersion = defaultOptions.getSdkVersion();
9293

93-
final String name = BuildConfig.SENTRY_SPRING_JAKARTA_SDK_NAME;
94+
final String name = BuildConfig.SENTRY_SPRING_7_SDK_NAME;
9495
final String version = BuildConfig.VERSION_NAME;
9596
sdkVersion = SdkVersion.updateSdkVersion(sdkVersion, name, version);
9697

sentry-spring-7/src/main/java/io/sentry/spring/jakarta/SentrySpringFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void configureScope(
111111
final @NotNull IScopes scopes, final @NotNull HttpServletRequest request) {
112112
if (scopes.getOptions().isSendDefaultPii()
113113
&& qualifiesForCaching(request, scopes.getOptions().getMaxRequestBodySize())) {
114-
return new ContentCachingRequestWrapper(request);
114+
return new ContentCachingRequestWrapper(request, 0);
115115
}
116116
return request;
117117
}

sentry-spring-7/src/main/java/io/sentry/spring/jakarta/checkin/SentryQuartzConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.jakewharton.nopen.annotation.Open;
44
import org.jetbrains.annotations.ApiStatus;
5-
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
5+
import org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer;
66
import org.springframework.context.annotation.Bean;
77
import org.springframework.context.annotation.Configuration;
88
import org.springframework.core.Ordered;

sentry-spring-7/src/main/java/io/sentry/spring/jakarta/checkin/SentrySchedulerFactoryBeanCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.sentry.quartz.SentryJobListener;
44
import org.jetbrains.annotations.ApiStatus;
5-
import org.springframework.boot.autoconfigure.quartz.SchedulerFactoryBeanCustomizer;
5+
import org.springframework.boot.quartz.autoconfigure.SchedulerFactoryBeanCustomizer;
66
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
77

88
@ApiStatus.Experimental

sentry-spring-7/src/main/java/io/sentry/spring/jakarta/webflux/SentryRequestResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public SentryRequestResolver(final @NotNull IScopes scopes) {
4949
@NotNull
5050
Map<String, String> resolveHeadersMap(final HttpHeaders request) {
5151
final Map<String, String> headersMap = new HashMap<>();
52-
for (Map.Entry<String, List<String>> entry : request.entrySet()) {
52+
for (Map.Entry<String, List<String>> entry : request.headerSet()) {
5353
// do not copy personal information identifiable headers
5454
String headerName = entry.getKey();
5555
if (scopes.getOptions().isSendDefaultPii()

sentry-spring-7/src/test/kotlin/io/sentry/spring/jakarta/EnableSentryTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import io.sentry.ITransportFactory
66
import io.sentry.Integration
77
import io.sentry.Sentry
88
import io.sentry.SentryOptions
9+
import io.sentry.spring7.BuildConfig
910
import io.sentry.transport.ITransport
1011
import kotlin.test.Test
1112
import org.assertj.core.api.Assertions.assertThat

sentry-spring-7/src/test/kotlin/io/sentry/spring/jakarta/mvc/SentrySpringIntegrationTest.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ import org.mockito.kotlin.whenever
4343
import org.springframework.beans.factory.annotation.Autowired
4444
import org.springframework.boot.autoconfigure.SpringBootApplication
4545
import org.springframework.boot.test.context.SpringBootTest
46-
import org.springframework.boot.test.web.client.TestRestTemplate
47-
import org.springframework.boot.test.web.server.LocalServerPort
46+
import org.springframework.boot.web.server.test.LocalServerPort
47+
import org.springframework.boot.web.server.test.client.TestRestTemplate
4848
import org.springframework.boot.web.servlet.FilterRegistrationBean
4949
import org.springframework.context.annotation.Bean
5050
import org.springframework.context.annotation.Configuration
@@ -110,7 +110,7 @@ class SentrySpringIntegrationTest {
110110
fun `attaches request and user information to SentryEvents`() {
111111
val restTemplate = TestRestTemplate().withBasicAuth("user", "password")
112112
val headers = HttpHeaders()
113-
headers["X-FORWARDED-FOR"] = listOf("169.128.0.1")
113+
headers.put("X-FORWARDED-FOR", listOf("169.128.0.1"))
114114
val entity = HttpEntity<Void>(headers)
115115

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

182182
restTemplate.exchange("http://localhost:$port/hello", HttpMethod.GET, entity, Void::class.java)
@@ -530,7 +530,10 @@ open class SecurityConfiguration {
530530
@Bean
531531
@Throws(Exception::class)
532532
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
533-
http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic()
533+
http
534+
.csrf { it.disable() }
535+
.authorizeHttpRequests { it.anyRequest().authenticated() }
536+
.httpBasic {}
534537

535538
return http.build()
536539
}

0 commit comments

Comments
 (0)