Skip to content

Commit 7d72974

Browse files
committed
Merge branch 'master' into improve-test-coverage
2 parents 0f5f126 + d1abf29 commit 7d72974

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/main/java/org/jvnet/jenkins/plugins/nodelabelparameter/NextLabelCause.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import hudson.model.Cause.UpstreamCause;
44
import hudson.model.Run;
5+
import java.util.Objects;
56

67
/**
78
* @author domi
@@ -34,13 +35,16 @@ public boolean equals(Object o) {
3435

3536
NextLabelCause that = (NextLabelCause) o;
3637

37-
return label.equals(that.label);
38+
return Objects.equals(label, that.label);
3839
}
3940

4041
@Override
4142
public int hashCode() {
4243
int result = super.hashCode();
43-
result = 31 * result + label.hashCode();
44+
result = 31 * result;
45+
if (label != null) {
46+
result = result + label.hashCode();
47+
}
4448
return result;
4549
}
4650
}

src/test/java/org/jvnet/jenkins/plugins/nodelabelparameter/NextLabelCauseTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import hudson.model.FreeStyleBuild;
44
import hudson.model.FreeStyleProject;
55
import nl.jqno.equalsverifier.EqualsVerifier;
6-
import nl.jqno.equalsverifier.Warning;
76
import org.junit.Assert;
87
import org.junit.Rule;
98
import org.junit.Test;
@@ -25,10 +24,8 @@ public void testGetShortDescription() throws Exception {
2524

2625
@Test
2726
public void testEqualsContract() {
28-
EqualsVerifier.forClass(LabelParameterValue.class)
29-
.usingGetClass()
30-
.suppress(Warning.NONFINAL_FIELDS)
31-
.withIgnoredFields("description", "nextLabels")
32-
.verify();
27+
// The UpstreamCause base class of NextLabelCause complicates the equals contract.
28+
// Intentionally use the simple() verifier.
29+
EqualsVerifier.simple().forClass(NextLabelCause.class).verify();
3330
}
3431
}

0 commit comments

Comments
 (0)