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,14 +38,28 @@ 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 @ Nullable
4646 public static String getVersion () {
4747 Package pkg = SpringVersion .class .getPackage ();
48- return (pkg != null ? pkg .getImplementationVersion () : null );
48+ String version = (pkg != null ? pkg .getImplementationVersion () : null );
49+ if (version != null ) {
50+ int idx = version .indexOf ('.' ); // after major
51+ if (idx != -1 ) {
52+ idx = version .indexOf ('.' , idx + 1 ); // after minor
53+ if (idx != -1 ) {
54+ idx = version .indexOf ('.' , idx + 1 ); // after patch
55+ if (idx != -1 ) {
56+ // Ignore anything beyond "major.minor.patch"
57+ version = version .substring (0 , idx );
58+ }
59+ }
60+ }
61+ }
62+ return version ;
4963 }
5064
5165}
You can’t perform that action at this time.
0 commit comments