-
-
Notifications
You must be signed in to change notification settings - Fork 441
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
Show warning if incompatible spring boot version is detected #3233
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
06c8bea
check for spring boot version and show warning on startup if incompat…
lbloder 9100886
add changelog
lbloder 9859b23
Merge branch 'main' into feat/detect-wrong-spring-version
lbloder f0e2eff
Update CHANGELOG.md
lbloder 740d816
Merge branch 'main' into feat/detect-wrong-spring-version
lbloder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...-boot-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentrySpringVersionChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.sentry.spring.boot.jakarta; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.springframework.boot.SpringBootVersion; | ||
import org.springframework.boot.context.event.ApplicationContextInitializedEvent; | ||
import org.springframework.context.ApplicationListener; | ||
|
||
final class SentrySpringVersionChecker | ||
implements ApplicationListener<ApplicationContextInitializedEvent> { | ||
|
||
private static final Log logger = LogFactory.getLog(SentrySpringVersionChecker.class); | ||
|
||
@Override | ||
public void onApplicationEvent(ApplicationContextInitializedEvent event) { | ||
|
||
if (!SpringBootVersion.getVersion().startsWith("3")) { | ||
logger.warn("############################### WARNING ###############################"); | ||
logger.warn("## ##"); | ||
logger.warn("## !Incompatible Spring Boot Version detected! ##"); | ||
logger.warn("## Please see the sentry docs linked below ##"); | ||
logger.warn("## Choose your Spring Boot version and ##"); | ||
logger.warn("## install the matching dependency ##"); | ||
logger.warn("## ##"); | ||
logger.warn("## https://docs.sentry.io/platforms/java/guides/spring-boot/#install ##"); | ||
logger.warn("## ##"); | ||
logger.warn("#######################################################################"); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
sentry-spring-boot-jakarta/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.springframework.context.ApplicationListener=io.sentry.spring.boot.jakarta.SentrySpringVersionChecker | ||
30 changes: 30 additions & 0 deletions
30
sentry-spring-boot/src/main/java/io/sentry/spring/boot/SentrySpringVersionChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.sentry.spring.boot; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.springframework.boot.SpringBootVersion; | ||
import org.springframework.boot.context.event.ApplicationContextInitializedEvent; | ||
import org.springframework.context.ApplicationListener; | ||
|
||
final class SentrySpringVersionChecker | ||
implements ApplicationListener<ApplicationContextInitializedEvent> { | ||
|
||
private static final Log logger = LogFactory.getLog(SentrySpringVersionChecker.class); | ||
|
||
@Override | ||
public void onApplicationEvent(ApplicationContextInitializedEvent event) { | ||
|
||
if (!SpringBootVersion.getVersion().startsWith("2")) { | ||
logger.warn("############################### WARNING ###############################"); | ||
logger.warn("## ##"); | ||
logger.warn("## !Incompatible Spring Boot Version detected! ##"); | ||
logger.warn("## Please see the sentry docs linked below ##"); | ||
logger.warn("## Choose your Spring Boot version and ##"); | ||
logger.warn("## install the matching dependency ##"); | ||
logger.warn("## ##"); | ||
logger.warn("## https://docs.sentry.io/platforms/java/guides/spring-boot/#install ##"); | ||
logger.warn("## ##"); | ||
logger.warn("#######################################################################"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h
does this still work with Spring3.3.0-M2
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with
3.3.0-M2
and is working as expected. Seems like this change was only targetingauto-configuration
.Also the current documentation for
3.3.0-M2
mentionsspring.factories
as the place to register listeners: https://docs.spring.io/spring-boot/docs/3.3.0-M2/reference/htmlsingle/#features.spring-application.application-events-and-listeners.