Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Spring Boot Jakarta to Spring Boot 3.0.0-RC2 #2347

Merged
merged 26 commits into from Nov 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cbf6abf
Use Java 17 on CI
adinauer Oct 13, 2022
99506f3
Revert "Use Java 17 on CI"
adinauer Oct 13, 2022
4e0ea93
Merge branch 'main' into feat/6.6.x
adinauer Oct 17, 2022
0b78c36
Support newer versions of Spring and Spring Boot (#2289)
adinauer Oct 18, 2022
f9a1963
Use artifacts / coverage from Java 17 instead of 11 build
adinauer Oct 19, 2022
e85ea16
release: 6.7.0-alpha.1
getsentry-bot Oct 19, 2022
00a39a6
add spring-jakarta modules to bug report template (#2313)
lbloder Oct 19, 2022
db806e5
Merge branch 'main' into feat/6.7.x
adinauer Oct 20, 2022
40d23d2
Add setup java for Java 17 compatibility in codeql analysis
adinauer Oct 20, 2022
5861971
Add new Spring Jakarta modules to `.craft.yml` (#2312)
adinauer Oct 31, 2022
31f8bdd
Merge branch 'main' into feat/6.7.x
adinauer Oct 31, 2022
cc7e1ff
Merge branch 'feat/6.7.x' of github.com:getsentry/sentry-java into fe…
adinauer Oct 31, 2022
03f90da
Merge branch 'main' into feat/6.7.x
adinauer Oct 31, 2022
f8f57b7
update to Spring Boot 3.0.0-RC1 disable jakarta transformer, fix depr…
lbloder Nov 8, 2022
306b9fe
remove -Xlint:-deprecation arg from jakarta samples
lbloder Nov 8, 2022
aac93e7
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
lbloder Nov 8, 2022
b3bd461
add changelog, cr
lbloder Nov 9, 2022
91f2954
use methodName var
lbloder Nov 9, 2022
3a12185
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
lbloder Nov 9, 2022
a7a6407
upgrade to SpringBoot RC2, reactivate ignored Test due to Bugfix in S…
lbloder Nov 11, 2022
155fb62
Format code
getsentry-bot Nov 11, 2022
a03652b
Update CHANGELOG.md
adinauer Nov 11, 2022
c412f8e
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
adinauer Nov 11, 2022
898b575
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
adinauer Nov 11, 2022
4c8cafa
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
lbloder Nov 11, 2022
1653497
Merge branch 'main' into feat/spring-boot-3.0.0-RC1
lbloder Nov 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests-benchmarks.yml
Expand Up @@ -91,4 +91,4 @@ jobs:
config: sentry-android-integration-tests/metrics-test.yml
sauce-user: ${{ secrets.SAUCE_USERNAME }}
sauce-key: ${{ secrets.SAUCE_ACCESS_KEY }}
if: env.SAUCE_USERNAME != null
if: env.SAUCE_USERNAME != null
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@

- Fix `Gpu.vendorId` should be a String ([#2343](https://github.com/getsentry/sentry-java/pull/2343))

### Features

- Update Spring Boot Jakarta to Spring Boot 3.0.0-RC2 ([#2347](https://github.com/getsentry/sentry-java/pull/2347))

## 6.7.0

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Expand Up @@ -5,7 +5,7 @@ object Config {
val kotlinStdLib = "stdlib-jdk8"

val springBootVersion = "2.7.4"
val springBoot3Version = "3.0.0-M5"
val springBoot3Version = "3.0.0-RC2"
val kotlinCompatibleLanguageVersion = "1.4"

val composeVersion = "1.1.1"
Expand Down
Expand Up @@ -59,10 +59,6 @@ tasks.withType<KotlinCompile> {
}
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:-deprecation")
}

task("jakartaTransformation", JavaExec::class) {
main = "org.eclipse.transformer.cli.JakartaTransformerCLI"
classpath = configurations.getByName("jakartaTransform") // sourceSets["main"].compileClasspath
Expand Down
@@ -1,5 +1,7 @@
package io.sentry.samples.spring.boot.jakarta;

import io.sentry.ISpan;
import io.sentry.Sentry;
import io.sentry.spring.jakarta.tracing.SentrySpan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -16,12 +18,19 @@ public class PersonService {
private static final Logger LOGGER = LoggerFactory.getLogger(PersonService.class);

private final JdbcTemplate jdbcTemplate;
private int createCount = 0;

public PersonService(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}

Person create(Person person) {
createCount++;
final ISpan span = Sentry.getSpan();
if (span != null) {
span.setMeasurement("create_count", createCount);
}

jdbcTemplate.update(
"insert into person (firstName, lastName) values (?, ?)",
person.getFirstName(),
Expand Down
Expand Up @@ -4,27 +4,27 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public class SecurityConfiguration {

// this API is meant to be consumed by non-browser clients thus the CSRF protection is not needed.
@Override
@SuppressWarnings("lgtm[java/spring-disabled-csrf-protection]")
protected void configure(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic();
@Bean
public SecurityFilterChain filterChain(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeHttpRequests().anyRequest().authenticated().and().httpBasic();

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection

CSRF vulnerability due to protection being disabled.

return http.build();
}

@Bean
@Override
public @NotNull UserDetailsService userDetailsService() {
public @NotNull InMemoryUserDetailsManager userDetailsService() {
final PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();

final UserDetails user =
Expand Down
Expand Up @@ -70,7 +70,3 @@ task("jakartaTransformation", JavaExec::class) {
classpath = configurations.getByName("jakartaTransform") // sourceSets["main"].compileClasspath
args = listOf("../sentry-samples-spring/src/main/java/io/sentry/samples/spring", "src/main/java/io/sentry/samples/spring/jakarta", "-o", "-tf", "sentry-jakarta-text-master.properties")
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:-deprecation")
}
Expand Up @@ -4,29 +4,27 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public class SecurityConfiguration {

// this API is meant to be consumed by non-browser clients thus the CSRF protection is not needed.
@Override
@SuppressWarnings("lgtm[java/spring-disabled-csrf-protection]")
protected void configure(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic();
@Bean
public SecurityFilterChain filterChain(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeHttpRequests().anyRequest().authenticated().and().httpBasic();

Check failure

Code scanning / CodeQL

Disabled Spring CSRF protection

CSRF vulnerability due to protection being disabled.

return http.build();
}

@Bean
@Override
public @NotNull UserDetailsService userDetailsService() {
public @NotNull InMemoryUserDetailsManager userDetailsService() {
final PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();

final UserDetails user =
Expand Down
3 changes: 1 addition & 2 deletions sentry-spring-boot-starter-jakarta/build.gradle.kts
@@ -1,4 +1,3 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down Expand Up @@ -128,7 +127,7 @@ task("jakartaMainClassTransformation", JavaExec::class) {
args = listOf("../sentry-spring-boot-starter/src/test/kotlin/com/acme", "src/test/kotlin/com/acme", "-o", "-tf", "sentry-jakarta-text-master.properties")
}

tasks.named("build").dependsOn("jakartaTransformation")
// tasks.named("build").dependsOn("jakartaTransformation")

buildConfig {
useJavaOutput()
Expand Down
Expand Up @@ -8,6 +8,7 @@ import io.sentry.checkTransaction
import io.sentry.spring.jakarta.tracing.SentrySpan
import io.sentry.transport.ITransport
import org.assertj.core.api.Assertions.assertThat
import org.junit.Ignore
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.anyOrNull
Expand All @@ -32,21 +33,19 @@ import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.core.userdetails.User
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.security.crypto.factory.PasswordEncoderFactories
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.provisioning.InMemoryUserDetailsManager
import org.springframework.security.web.SecurityFilterChain
import org.springframework.stereotype.Service
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RestController
import java.lang.RuntimeException
import kotlin.test.BeforeTest
import kotlin.test.Test

Expand Down Expand Up @@ -270,17 +269,10 @@ open class HelloService {
}

@Configuration
open class SecurityConfiguration : WebSecurityConfigurerAdapter() {

override fun configure(http: HttpSecurity) {
http.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic()
}
open class SecurityConfiguration {

@Bean
override fun userDetailsService(): UserDetailsService {
open fun userDetailsService(): InMemoryUserDetailsManager {
val encoder: PasswordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder()
val user: UserDetails = User
.builder()
Expand All @@ -291,6 +283,17 @@ open class SecurityConfiguration : WebSecurityConfigurerAdapter() {
.build()
return InMemoryUserDetailsManager(user)
}

@Bean
@Throws(Exception::class)
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
http.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic()

return http.build()
}
}

class CustomException(message: String) : RuntimeException(message)
Expand Down
Expand Up @@ -32,21 +32,19 @@ import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.core.userdetails.User
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.security.crypto.factory.PasswordEncoderFactories
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.security.provisioning.InMemoryUserDetailsManager
import org.springframework.security.web.SecurityFilterChain
import org.springframework.stereotype.Service
import org.springframework.test.context.junit4.SpringRunner
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RestController
import java.lang.RuntimeException
import kotlin.test.BeforeTest
import kotlin.test.Test

Expand Down Expand Up @@ -270,17 +268,10 @@ open class HelloService {
}

@Configuration
open class SecurityConfiguration : WebSecurityConfigurerAdapter() {

override fun configure(http: HttpSecurity) {
http.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic()
}
open class SecurityConfiguration {

@Bean
override fun userDetailsService(): UserDetailsService {
open fun userDetailsService(): InMemoryUserDetailsManager {
val encoder: PasswordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder()
val user: UserDetails = User
.builder()
Expand All @@ -291,6 +282,17 @@ open class SecurityConfiguration : WebSecurityConfigurerAdapter() {
.build()
return InMemoryUserDetailsManager(user)
}

@Bean
@Throws(Exception::class)
open fun filterChain(http: HttpSecurity): SecurityFilterChain {
http.csrf().disable()
.authorizeRequests().anyRequest().authenticated()
.and()
.httpBasic()

return http.build()
}
}

class CustomException(message: String) : RuntimeException(message)
Expand Down
13 changes: 5 additions & 8 deletions sentry-spring-jakarta/build.gradle.kts
@@ -1,6 +1,7 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.plugin.SpringBootPlugin


plugins {
Expand All @@ -19,9 +20,9 @@ repositories {
maven { url = uri("https://repo.spring.io/milestone") }
}

the<io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension>().apply {
the<DependencyManagementExtension>().apply {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:${Config.springBoot3Version}")
mavenBom(SpringBootPlugin.BOM_COORDINATES)
}
}

Expand Down Expand Up @@ -108,10 +109,6 @@ tasks {
}
}

tasks.withType<JavaCompile> {
options.compilerArgs.add("-Xlint:-deprecation")
}

task("jakartaTransformation", JavaExec::class) {
main = "org.eclipse.transformer.cli.JakartaTransformerCLI"
classpath = configurations.getByName("jakartaTransform") // sourceSets["main"].compileClasspath
Expand All @@ -124,7 +121,7 @@ task("jakartaTestTransformation", JavaExec::class) {
args = listOf("../sentry-spring/src/test/kotlin/io/sentry/spring", "src/test/kotlin/io/sentry/spring/jakarta", "-o", "-tf", "sentry-jakarta-text-master.properties")
}

tasks.named("build").dependsOn("jakartaTransformation")
// tasks.named("build").dependsOn("jakartaTransformation")

buildConfig {
useJavaOutput()
Expand Down
Expand Up @@ -45,7 +45,9 @@ public SentrySpanClientHttpRequestInterceptor(final @NotNull IHub hub) {
}

final ISpan span = activeSpan.startChild("http.client");
span.setDescription(request.getMethodValue() + " " + request.getURI());
final String methodName =
request.getMethod() != null ? request.getMethod().name() : "unknown";
span.setDescription(methodName + " " + request.getURI());

final SentryTraceHeader sentryTraceHeader = span.toSentryTrace();

Expand All @@ -63,8 +65,8 @@ public SentrySpanClientHttpRequestInterceptor(final @NotNull IHub hub) {
try {
response = execution.execute(request, body);
// handles both success and error responses
span.setStatus(SpanStatus.fromHttpStatusCode(response.getRawStatusCode()));
responseStatusCode = response.getRawStatusCode();
span.setStatus(SpanStatus.fromHttpStatusCode(response.getStatusCode().value()));
responseStatusCode = response.getStatusCode().value();
return response;
} catch (Throwable e) {
// handles cases like connection errors
Expand All @@ -84,8 +86,10 @@ private void addBreadcrumb(
final @NotNull byte[] body,
final @Nullable Integer responseStatusCode,
final @Nullable ClientHttpResponse response) {
final String methodName = request.getMethod() != null ? request.getMethod().name() : "unknown";

final Breadcrumb breadcrumb =
Breadcrumb.http(request.getURI().toString(), request.getMethodValue(), responseStatusCode);
Breadcrumb.http(request.getURI().toString(), methodName, responseStatusCode);
breadcrumb.setData("request_body_size", body.length);

final Hint hint = new Hint();
Expand Down
Expand Up @@ -66,7 +66,7 @@ public SentrySpanClientWebRequestFilter(final @NotNull IHub hub) {
return next.exchange(clientRequestWithSentryTraceHeader)
.flatMap(
response -> {
span.setStatus(SpanStatus.fromHttpStatusCode(response.rawStatusCode()));
span.setStatus(SpanStatus.fromHttpStatusCode(response.statusCode().value()));
addBreadcrumb(request, response);
span.finish();
return Mono.just(response);
Expand All @@ -87,7 +87,7 @@ private void addBreadcrumb(
Breadcrumb.http(
request.url().toString(),
request.method().name(),
response != null ? response.rawStatusCode() : null);
response != null ? response.statusCode().value() : null);

final Hint hint = new Hint();
hint.set(SPRING_EXCHANGE_FILTER_REQUEST, request);
Expand Down
Expand Up @@ -25,7 +25,9 @@ public SentryRequestResolver(final @NotNull IHub hub) {

public @NotNull Request resolveSentryRequest(final @NotNull ServerHttpRequest httpRequest) {
final Request sentryRequest = new Request();
sentryRequest.setMethod(httpRequest.getMethodValue());
final String methodName =
httpRequest.getMethod() != null ? httpRequest.getMethod().name() : "unknown";
sentryRequest.setMethod(methodName);
sentryRequest.setQueryString(httpRequest.getURI().getQuery());
sentryRequest.setUrl(httpRequest.getURI().toString());
sentryRequest.setHeaders(resolveHeadersMap(httpRequest.getHeaders()));
Expand Down