File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed
main/java/org/jvnet/jenkins/plugins/nodelabelparameter
test/java/org/jvnet/jenkins/plugins/nodelabelparameter Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import hudson .model .Cause .UpstreamCause ;
4
4
import hudson .model .Run ;
5
+ import java .util .Objects ;
5
6
6
7
/**
7
8
* @author domi
@@ -34,13 +35,16 @@ public boolean equals(Object o) {
34
35
35
36
NextLabelCause that = (NextLabelCause ) o ;
36
37
37
- return label .equals (that .label );
38
+ return Objects .equals (label , that .label );
38
39
}
39
40
40
41
@ Override
41
42
public int hashCode () {
42
43
int result = super .hashCode ();
43
- result = 31 * result + label .hashCode ();
44
+ result = 31 * result ;
45
+ if (label != null ) {
46
+ result = result + label .hashCode ();
47
+ }
44
48
return result ;
45
49
}
46
50
}
Original file line number Diff line number Diff line change 3
3
import hudson .model .FreeStyleBuild ;
4
4
import hudson .model .FreeStyleProject ;
5
5
import nl .jqno .equalsverifier .EqualsVerifier ;
6
- import nl .jqno .equalsverifier .Warning ;
7
6
import org .junit .Assert ;
8
7
import org .junit .Rule ;
9
8
import org .junit .Test ;
@@ -25,10 +24,8 @@ public void testGetShortDescription() throws Exception {
25
24
26
25
@ Test
27
26
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 ();
33
30
}
34
31
}
You can’t perform that action at this time.
0 commit comments