Skip to content

Commit c3baa01

Browse files
committed
Merge branch '7.0.x'
2 parents c0b7494 + c048074 commit c3baa01

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

spring-core/src/main/java/org/springframework/core/SpringVersion.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)