Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent equals and hashCode #8381

Merged
merged 4 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,10 @@ public boolean equals(Object o)
return Objects.equals(bucket, that.bucket) &&
Objects.equals(path, that.path);
}
}

@Override
public int hashCode()
{
return Objects.hash(bucket, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;

@JsonTypeName("loadingLookup")
Expand Down Expand Up @@ -137,6 +138,11 @@ public boolean equals(Object o)
return reverseLoadingCache != null
? reverseLoadingCache.equals(that.reverseLoadingCache)
: that.reverseLoadingCache == null;
}

@Override
public int hashCode()
{
return Objects.hash(dataFetcher, loadingCache, reverseLoadingCache);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.joda.time.Period;

import javax.annotation.Nullable;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;

@JsonTypeName("pollingLookup")
Expand Down Expand Up @@ -155,6 +156,11 @@ public boolean equals(Object o)
? (that.cacheFactory != null
&& cacheFactory.getClass() == (that.cacheFactory).getClass())
: that.cacheFactory == null;
}

@Override
public int hashCode()
{
return Objects.hash(pollPeriod, dataFetcher, cacheFactory);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public class JdbcDataFetcher implements DataFetcher<String, String>
{
Expand Down Expand Up @@ -183,6 +184,12 @@ public boolean equals(Object o)

}

@Override
public int hashCode()
{
return Objects.hash(connectorConfig, table, keyColumn, valueColumn);
}

@Override
public String toString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,10 @@ public boolean equals(Object o)

return true;
}

@Override
public int hashCode()
{
return Objects.hash(name, fieldName, estimator, isVariancePop);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public boolean equals(Object o)
return o != null && o instanceof IdentityExtractionFn;
}

@Override
public int hashCode()
{
return 0;
}

public static final IdentityExtractionFn getInstance()
{
return INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public boolean equals(Object o)
return true;
}

@Override
public int hashCode()
{
return 0;
}

@Override
public String toString()
{
Expand Down Expand Up @@ -269,6 +275,12 @@ public boolean equals(Object o)
return true;
}

@Override
public int hashCode()
{
return 0;
}

@Override
public String toString()
{
Expand Down Expand Up @@ -314,10 +326,15 @@ public boolean equals(Object o)
if (o == null || getClass() != o.getClass()) {
return false;
}

return true;
}

@Override
public int hashCode()
{
return 0;
}

@Override
public String toString()
{
Expand Down Expand Up @@ -410,10 +427,15 @@ public boolean equals(Object o)
if (o == null || getClass() != o.getClass()) {
return false;
}

return true;
}

@Override
public int hashCode()
{
return 0;
}

@Override
public byte[] getCacheKey()
{
Expand Down Expand Up @@ -461,6 +483,12 @@ public boolean equals(Object o)
return true;
}

@Override
public int hashCode()
{
return 0;
}

@Override
public byte[] getCacheKey()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ public boolean equals(Object o)
}
return super.equals(o);
}

@Override
public int hashCode()
{
return super.hashCode();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is it better to remove equals() from InsensitiveContainsSearchQuerySpec since it's just a syntax sugar for ContainsSearchQuerySpec with the false caseSensitive? Like, given a ContainsSearchQuerySpec with the false caseSensitive and an InsensitiveContainsSearchQuerySpec, should they equal to each other? I think they should be same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, removed. 👍

}
}