File tree Expand file tree Collapse file tree
spring-core/src/main/java/org/springframework/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,13 +38,27 @@ private SpringVersion() {
3838
3939
4040 /**
41- * Return the full version string of the present Spring codebase,
41+ * Return the "major.minor.patch" version string of the present Spring codebase,
4242 * or {@code null} if it cannot be determined.
4343 * @see Package#getImplementationVersion()
4444 */
4545 public static @ Nullable String getVersion () {
4646 Package pkg = SpringVersion .class .getPackage ();
47- return (pkg != null ? pkg .getImplementationVersion () : null );
47+ String version = (pkg != null ? pkg .getImplementationVersion () : null );
48+ if (version != null ) {
49+ int idx = version .indexOf ('.' ); // after major
50+ if (idx != -1 ) {
51+ idx = version .indexOf ('.' , idx + 1 ); // after minor
52+ if (idx != -1 ) {
53+ idx = version .indexOf ('.' , idx + 1 ); // after patch
54+ if (idx != -1 ) {
55+ // Ignore anything beyond "major.minor.patch"
56+ version = version .substring (0 , idx );
57+ }
58+ }
59+ }
60+ }
61+ return version ;
4862 }
4963
5064}
You can’t perform that action at this time.
0 commit comments