Skip to content

Commit 50a5e31

Browse files
committed
Fix comparision of identical snapshots
Closes gh-35860
1 parent 1955139 commit 50a5e31

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ArtifactVersionDependencyVersion.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.boot.build.bom.bomr.version;
1818

19+
import java.util.Objects;
1920
import java.util.Optional;
2021

2122
import org.apache.maven.artifact.versioning.ArtifactVersion;
@@ -79,7 +80,8 @@ private boolean isSameMinorAndNewerThan(ArtifactVersionDependencyVersion other)
7980
public int compareTo(DependencyVersion other) {
8081
if (other instanceof ArtifactVersionDependencyVersion otherArtifactDependencyVersion) {
8182
ArtifactVersion otherArtifactVersion = otherArtifactDependencyVersion.artifactVersion;
82-
if ("snapshot".equalsIgnoreCase(otherArtifactVersion.getQualifier())
83+
if ((!Objects.equals(this.artifactVersion.getQualifier(), otherArtifactVersion.getQualifier()))
84+
&& "snapshot".equalsIgnoreCase(otherArtifactVersion.getQualifier())
8385
&& otherArtifactVersion.getMajorVersion() == this.artifactVersion.getMajorVersion()
8486
&& otherArtifactVersion.getMinorVersion() == this.artifactVersion.getMinorVersion()
8587
&& otherArtifactVersion.getIncrementalVersion() == this.artifactVersion.getIncrementalVersion()) {

buildSrc/src/test/java/org/springframework/boot/build/bom/bomr/version/ArtifactVersionDependencyVersionTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ void isSameMinorAndNewerThanWhenVersionsAreTheSameShouldReturnFalse() {
9797
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.1.2"))).isFalse();
9898
}
9999

100+
@Test
101+
void isSameMinorAndNewerThanWhenSameSnapshotsShouldReturnFalse() {
102+
assertThat(version("3.1.2-SNAPSHOT").isSameMinorAndNewerThan(version("3.1.2-SNAPSHOT"))).isFalse();
103+
}
104+
100105
@Test
101106
void isSameMinorAndNewerThanWhenPatchIsNewerShouldReturnFalse() {
102107
assertThat(version("2.1.2").isSameMinorAndNewerThan(version("2.1.3"))).isFalse();

0 commit comments

Comments
 (0)