Skip to content

Commit c555b1e

Browse files
authored
Merge pull request #1299 from Vlatombe/incorrect-equals-hashCode
2 parents dc85747 + d8f39ff commit c555b1e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ public boolean equals(Object o) {
661661
if (this == o) return true;
662662
if (o == null || getClass() != o.getClass()) return false;
663663
KubernetesCloud that = (KubernetesCloud) o;
664-
return skipTlsVerify == that.skipTlsVerify &&
664+
return Objects.equals(name, that.name) &&
665+
skipTlsVerify == that.skipTlsVerify &&
665666
addMasterProxyEnvVars == that.addMasterProxyEnvVars &&
666667
capOnlyOnAlivePods == that.capOnlyOnAlivePods &&
667668
Objects.equals(containerCap, that.containerCap) &&
@@ -687,7 +688,7 @@ public boolean equals(Object o) {
687688

688689
@Override
689690
public int hashCode() {
690-
return Objects.hash(defaultsProviderTemplate, templates, serverUrl, serverCertificate, skipTlsVerify,
691+
return Objects.hash(name, defaultsProviderTemplate, templates, serverUrl, serverCertificate, skipTlsVerify,
691692
addMasterProxyEnvVars, capOnlyOnAlivePods, namespace, jnlpregistry, jenkinsUrl, jenkinsTunnel, credentialsId,
692693
containerCap, retentionTimeout, connectTimeout, readTimeout, podLabels, usageRestricted,
693694
maxRequestsPerHost, podRetention, useJenkinsProxy);

src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloudTest.java

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

33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertNull;
5+
import static org.junit.Assert.assertTrue;
56
import static org.junit.Assert.fail;
67

78
import java.util.ArrayList;
@@ -24,6 +25,7 @@
2425
import org.apache.commons.beanutils.PropertyUtils;
2526
import org.apache.commons.lang3.RandomStringUtils;
2627
import org.apache.commons.lang3.RandomUtils;
28+
import org.apache.commons.lang3.builder.EqualsBuilder;
2729
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.Always;
2830
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention;
2931
import org.csanchez.jenkins.plugins.kubernetes.volumes.EmptyDirVolume;
@@ -244,7 +246,7 @@ public void copyConstructor() throws Exception {
244246

245247
KubernetesCloud copy = new KubernetesCloud("copy", cloud);
246248
assertEquals("copy", copy.name);
247-
assertEquals("Expected cloud from copy constructor to be equal to the source except for name", cloud, copy);
249+
assertTrue("Expected cloud from copy constructor to be equal to the source except for name", EqualsBuilder.reflectionEquals(cloud, copy, true, KubernetesCloud.class, "name"));
248250
}
249251

250252
@Test

0 commit comments

Comments
 (0)