Fix inconsistent equals and hashCode (#8381)

* Fix inconsistent equals and hashCode

* Patch comments

* Remove equals and hashCode from InsensitiveContainsSearchQuerySpec
This commit is contained in:
Benedict Jin 2019-09-04 13:48:08 +08:00 committed by GitHub
parent ee4ebb496a
commit de18840412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 15 deletions

View File

@ -72,5 +72,10 @@ public class GoogleBlob
return Objects.equals(bucket, that.bucket) &&
Objects.equals(path, that.path);
}
}
@Override
public int hashCode()
{
return Objects.hash(bucket, path);
}
}

View File

@ -29,6 +29,7 @@ import org.apache.druid.server.lookup.cache.loading.LoadingCache;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
@JsonTypeName("loadingLookup")
@ -137,6 +138,11 @@ public class LoadingLookupFactory implements LookupExtractorFactory
return reverseLoadingCache != null
? reverseLoadingCache.equals(that.reverseLoadingCache)
: that.reverseLoadingCache == null;
}
@Override
public int hashCode()
{
return Objects.hash(dataFetcher, loadingCache, reverseLoadingCache);
}
}

View File

@ -30,6 +30,7 @@ import org.apache.druid.server.lookup.cache.polling.PollingCacheFactory;
import org.joda.time.Period;
import javax.annotation.Nullable;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
@JsonTypeName("pollingLookup")
@ -155,6 +156,11 @@ public class PollingLookupFactory implements LookupExtractorFactory
? (that.cacheFactory != null
&& cacheFactory.getClass() == (that.cacheFactory).getClass())
: that.cacheFactory == null;
}
@Override
public int hashCode()
{
return Objects.hash(pollPeriod, dataFetcher, cacheFactory);
}
}

View File

@ -38,6 +38,7 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
public class JdbcDataFetcher implements DataFetcher<String, String>
{
@ -183,6 +184,12 @@ public class JdbcDataFetcher implements DataFetcher<String, String>
}
@Override
public int hashCode()
{
return Objects.hash(connectorConfig, table, keyColumn, valueColumn);
}
@Override
public String toString()
{

View File

@ -150,4 +150,10 @@ public class StandardDeviationPostAggregator implements PostAggregator
return true;
}
@Override
public int hashCode()
{
return Objects.hash(name, fieldName, estimator, isVariancePop);
}
}

View File

@ -82,6 +82,12 @@ public class IdentityExtractionFn implements ExtractionFn
return o != null && o instanceof IdentityExtractionFn;
}
@Override
public int hashCode()
{
return 0;
}
public static final IdentityExtractionFn getInstance()
{
return INSTANCE;

View File

@ -87,6 +87,12 @@ public class StringComparators
return true;
}
@Override
public int hashCode()
{
return 0;
}
@Override
public String toString()
{
@ -269,6 +275,12 @@ public class StringComparators
return true;
}
@Override
public int hashCode()
{
return 0;
}
@Override
public String toString()
{
@ -314,10 +326,15 @@ public class StringComparators
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode()
{
return 0;
}
@Override
public String toString()
{
@ -410,10 +427,15 @@ public class StringComparators
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode()
{
return 0;
}
@Override
public byte[] getCacheKey()
{
@ -461,6 +483,12 @@ public class StringComparators
return true;
}
@Override
public int hashCode()
{
return 0;
}
@Override
public byte[] getCacheKey()
{

View File

@ -41,16 +41,4 @@ public class InsensitiveContainsSearchQuerySpec extends ContainsSearchQuerySpec
"value=" + getValue() +
"}";
}
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return super.equals(o);
}
}