Skip to content

Commit

Permalink
Merge pull request #1299 from Vlatombe/incorrect-equals-hashCode
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe authored Jan 25, 2023
2 parents dc85747 + d8f39ff commit c555b1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
KubernetesCloud that = (KubernetesCloud) o;
return skipTlsVerify == that.skipTlsVerify &&
return Objects.equals(name, that.name) &&
skipTlsVerify == that.skipTlsVerify &&
addMasterProxyEnvVars == that.addMasterProxyEnvVars &&
capOnlyOnAlivePods == that.capOnlyOnAlivePods &&
Objects.equals(containerCap, that.containerCap) &&
Expand All @@ -687,7 +688,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(defaultsProviderTemplate, templates, serverUrl, serverCertificate, skipTlsVerify,
return Objects.hash(name, defaultsProviderTemplate, templates, serverUrl, serverCertificate, skipTlsVerify,
addMasterProxyEnvVars, capOnlyOnAlivePods, namespace, jnlpregistry, jenkinsUrl, jenkinsTunnel, credentialsId,
containerCap, retentionTimeout, connectTimeout, readTimeout, podLabels, usageRestricted,
maxRequestsPerHost, podRetention, useJenkinsProxy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.ArrayList;
Expand All @@ -24,6 +25,7 @@
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.Always;
import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention;
import org.csanchez.jenkins.plugins.kubernetes.volumes.EmptyDirVolume;
Expand Down Expand Up @@ -244,7 +246,7 @@ public void copyConstructor() throws Exception {

KubernetesCloud copy = new KubernetesCloud("copy", cloud);
assertEquals("copy", copy.name);
assertEquals("Expected cloud from copy constructor to be equal to the source except for name", cloud, copy);
assertTrue("Expected cloud from copy constructor to be equal to the source except for name", EqualsBuilder.reflectionEquals(cloud, copy, true, KubernetesCloud.class, "name"));
}

@Test
Expand Down

0 comments on commit c555b1e

Please sign in to comment.