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

Get rid of "is not eligible for getting processed by all BeanPostProcessors" warnings in Spring Boot #3108

Merged
merged 3 commits into from
Dec 20, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Send breadcrumbs and client error in `SentryOkHttpEventListener` even without transactions ([#3087](https://github.com/getsentry/sentry-java/pull/3087))
- Keep `io.sentry.exception.SentryHttpClientException` from obfuscation to display proper issue title on Sentry ([#3093](https://github.com/getsentry/sentry-java/pull/3093))
- (Android) Fix wrong activity transaction duration in case SDK init is deferred ([#3092](https://github.com/getsentry/sentry-java/pull/3092))
- Get rid of "is not eligible for getting processed by all BeanPostProcessors" warnings in Spring Boot ([#3108](https://github.com/getsentry/sentry-java/pull/3108))

### Dependencies

Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ object Config {
val kotlinStdLib = "stdlib-jdk8"

val springBootVersion = "2.7.5"
val springBoot3Version = "3.0.3"
val springBoot3Version = "3.2.0"
val kotlinCompatibleLanguageVersion = "1.4"

val composeVersion = "1.5.3"
Expand Down Expand Up @@ -116,7 +116,7 @@ object Config {
val fragment = "androidx.fragment:fragment-ktx:1.3.5"

val reactorCore = "io.projectreactor:reactor-core:3.5.3"
val contextPropagation = "io.micrometer:context-propagation:1.0.2"
val contextPropagation = "io.micrometer:context-propagation:1.1.0"

private val feignVersion = "11.6"
val feignCore = "io.github.openfeign:feign-core:$feignVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public class SecurityConfiguration {

// this API is meant to be consumed by non-browser clients thus the CSRF protection is not needed.
@SuppressWarnings("lgtm[java/spring-disabled-csrf-protection]")
@SuppressWarnings({"lgtm[java/spring-disabled-csrf-protection]", "removal"})
@Bean
public SecurityFilterChain filterChain(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeHttpRequests().anyRequest().authenticated().and().httpBasic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class SecurityConfiguration {

// this API is meant to be consumed by non-browser clients thus the CSRF protection is not needed.
@SuppressWarnings("lgtm[java/spring-disabled-csrf-protection]")
@SuppressWarnings({"lgtm[java/spring-disabled-csrf-protection]", "removal"})
@Bean
public SecurityFilterChain filterChain(final @NotNull HttpSecurity http) throws Exception {
http.csrf().disable().authorizeHttpRequests().anyRequest().authenticated().and().httpBasic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class io/sentry/spring/boot/jakarta/SentryWebfluxAutoConfiguration {
public class io/sentry/spring/boot/jakarta/graphql/SentryGraphqlAutoConfiguration {
public fun <init> ()V
public fun exceptionResolverAdapter ()Lio/sentry/spring/jakarta/graphql/SentryDataFetcherExceptionResolverAdapter;
public fun graphqlBeanPostProcessor ()Lio/sentry/spring/jakarta/graphql/SentryGraphqlBeanPostProcessor;
public static fun graphqlBeanPostProcessor ()Lio/sentry/spring/jakarta/graphql/SentryGraphqlBeanPostProcessor;
public fun sourceBuilderCustomizerWebflux (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lorg/springframework/boot/autoconfigure/graphql/GraphQlSourceBuilderCustomizer;
public fun sourceBuilderCustomizerWebmvc (Lio/sentry/spring/boot/jakarta/SentryProperties;)Lorg/springframework/boot/autoconfigure/graphql/GraphQlSourceBuilderCustomizer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SentryDataFetcherExceptionResolverAdapter exceptionResolverAdapter() {
}

@Bean
public SentryGraphqlBeanPostProcessor graphqlBeanPostProcessor() {
public static SentryGraphqlBeanPostProcessor graphqlBeanPostProcessor() {
return new SentryGraphqlBeanPostProcessor();
}
}
2 changes: 1 addition & 1 deletion sentry-spring-boot/api/sentry-spring-boot.api
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class io/sentry/spring/boot/SentryWebfluxAutoConfiguration {
public class io/sentry/spring/boot/graphql/SentryGraphqlAutoConfiguration {
public fun <init> ()V
public fun exceptionResolverAdapter ()Lio/sentry/spring/graphql/SentryDataFetcherExceptionResolverAdapter;
public fun graphqlBeanPostProcessor ()Lio/sentry/spring/graphql/SentryGraphqlBeanPostProcessor;
public static fun graphqlBeanPostProcessor ()Lio/sentry/spring/graphql/SentryGraphqlBeanPostProcessor;
public fun sourceBuilderCustomizerWebflux (Lio/sentry/spring/boot/SentryProperties;)Lorg/springframework/boot/autoconfigure/graphql/GraphQlSourceBuilderCustomizer;
public fun sourceBuilderCustomizerWebmvc (Lio/sentry/spring/boot/SentryProperties;)Lorg/springframework/boot/autoconfigure/graphql/GraphQlSourceBuilderCustomizer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public SentryDataFetcherExceptionResolverAdapter exceptionResolverAdapter() {
}

@Bean
public SentryGraphqlBeanPostProcessor graphqlBeanPostProcessor() {
public static SentryGraphqlBeanPostProcessor graphqlBeanPostProcessor() {
return new SentryGraphqlBeanPostProcessor();
}
}
3 changes: 2 additions & 1 deletion sentry-spring-jakarta/api/sentry-spring-jakarta.api
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ public final class io/sentry/spring/jakarta/graphql/SentryDgsSubscriptionHandler
public fun onSubscriptionResult (Ljava/lang/Object;Lio/sentry/IHub;Lio/sentry/graphql/ExceptionReporter;Lgraphql/execution/instrumentation/parameters/InstrumentationFieldFetchParameters;)Ljava/lang/Object;
}

public final class io/sentry/spring/jakarta/graphql/SentryGraphqlBeanPostProcessor : org/springframework/beans/factory/config/BeanPostProcessor {
public final class io/sentry/spring/jakarta/graphql/SentryGraphqlBeanPostProcessor : org/springframework/beans/factory/config/BeanPostProcessor, org/springframework/core/PriorityOrdered {
public fun <init> ()V
public fun getOrder ()I
public fun postProcessAfterInitialization (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
import org.jetbrains.annotations.ApiStatus;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.graphql.execution.BatchLoaderRegistry;

@ApiStatus.Internal
public final class SentryGraphqlBeanPostProcessor implements BeanPostProcessor {
public final class SentryGraphqlBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {

@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof BatchLoaderRegistry) {
return new SentryBatchLoaderRegistry((BatchLoaderRegistry) bean);
}
return bean;
}

@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void setValue(IHub value) {
}

@Override
@SuppressWarnings("deprecation")
public void reset() {
Sentry.setCurrentHub(NoOpHub.getInstance());
}
Expand Down
3 changes: 2 additions & 1 deletion sentry-spring/api/sentry-spring.api
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ public final class io/sentry/spring/graphql/SentryDgsSubscriptionHandler : io/se
public fun onSubscriptionResult (Ljava/lang/Object;Lio/sentry/IHub;Lio/sentry/graphql/ExceptionReporter;Lgraphql/execution/instrumentation/parameters/InstrumentationFieldFetchParameters;)Ljava/lang/Object;
}

public final class io/sentry/spring/graphql/SentryGraphqlBeanPostProcessor : org/springframework/beans/factory/config/BeanPostProcessor {
public final class io/sentry/spring/graphql/SentryGraphqlBeanPostProcessor : org/springframework/beans/factory/config/BeanPostProcessor, org/springframework/core/PriorityOrdered {
public fun <init> ()V
public fun getOrder ()I
public fun postProcessAfterInitialization (Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
import org.jetbrains.annotations.ApiStatus;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.graphql.execution.BatchLoaderRegistry;

@ApiStatus.Internal
public final class SentryGraphqlBeanPostProcessor implements BeanPostProcessor {
public final class SentryGraphqlBeanPostProcessor implements BeanPostProcessor, PriorityOrdered {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof BatchLoaderRegistry) {
return new SentryBatchLoaderRegistry((BatchLoaderRegistry) bean);
}
return bean;
}

@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
}
Loading