Skip to content

Commit

Permalink
Update errorprone, mockito, jacoco, checkerframework. (#17414)
Browse files Browse the repository at this point in the history
* Update errorprone, mockito, jacoco, checkerframework.

This patch updates various build and test dependencies, to see if they
cause unit tests on JDK 21 to behave more reliably.

* Update licenses, tests.

* Remove assertEquals.

* Repair two tests.

* Update some more tests.
  • Loading branch information
gianm authored Oct 28, 2024
1 parent 73675d0 commit 446a8f4
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.query.aggregation.datasketches.hll;

import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.datasketches.hll.HllSketch;
import org.apache.datasketches.hll.TgtHllType;
import org.apache.druid.java.util.common.StringEncoding;
Expand Down Expand Up @@ -120,11 +121,9 @@ public void testFinalizeComputatioNoRound()
}

@Test
public void testEqualsSameObject()
public void testEquals()
{
//noinspection EqualsWithItself
Assert.assertEquals(target, target);
Assert.assertArrayEquals(target.getCacheKey(), target.getCacheKey());
EqualsVerifier.forClass(HllSketchAggregatorFactory.class).usingGetClass().verify();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.data.input.kafka.KafkaRecordEntity;
import org.apache.druid.java.util.common.DateTimes;
import org.apache.druid.java.util.common.Pair;
Expand Down Expand Up @@ -72,15 +73,11 @@ public byte[] value()
}
);
private KafkaRecordEntity inputEntity;
private long timestamp = DateTimes.of("2021-06-24T00:00:00.000Z").getMillis();
private final long timestamp = DateTimes.of("2021-06-24T00:00:00.000Z").getMillis();

@Test
public void testSerde() throws JsonProcessingException
{
Assert.assertEquals(
KAFKAHEADERNOENCODE,
KAFKAHEADERNOENCODE
);
Assert.assertEquals(
KAFKAHEADERNOENCODE,
MAPPER.readValue(MAPPER.writeValueAsString(KAFKAHEADERNOENCODE), KafkaStringHeaderFormat.class)
Expand All @@ -92,6 +89,12 @@ public void testSerde() throws JsonProcessingException
);
}

@Test
public void testEquals()
{
EqualsVerifier.forClass(KafkaStringHeaderFormat.class).usingGetClass().verify();
}

@Test
public void testDefaultHeaderFormat()
{
Expand Down
5 changes: 5 additions & 0 deletions indexing-hadoop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
<!-- explicitly declare mockito-core dependency to make anaylize-dependencies happy when running with Java 8 -->
<dependency>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,22 @@ public String getFinalIndexZipFilePath()
@Override
public boolean equals(Object o)
{
if (o instanceof DataSegmentAndIndexZipFilePath) {
DataSegmentAndIndexZipFilePath that = (DataSegmentAndIndexZipFilePath) o;
return segment.equals(((DataSegmentAndIndexZipFilePath) o).getSegment())
&& tmpIndexZipFilePath.equals(that.getTmpIndexZipFilePath())
&& finalIndexZipFilePath.equals(that.getFinalIndexZipFilePath());
if (this == o) {
return true;
}
return false;
if (o == null || getClass() != o.getClass()) {
return false;
}
DataSegmentAndIndexZipFilePath that = (DataSegmentAndIndexZipFilePath) o;
return Objects.equals(segment, that.segment)
&& Objects.equals(tmpIndexZipFilePath, that.tmpIndexZipFilePath)
&& Objects.equals(finalIndexZipFilePath, that.finalIndexZipFilePath);
}

@Override
public int hashCode()
{
return Objects.hash(segment.getId(), tmpIndexZipFilePath);
return Objects.hash(segment, tmpIndexZipFilePath, finalIndexZipFilePath);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.timeline.DataSegment;
import org.apache.druid.timeline.SegmentId;
Expand Down Expand Up @@ -149,17 +150,9 @@ public void test_equals_allFieldsEqualValue_equal()
}

@Test
public void test_equals_sameObject_equal()
public void test_equals()
{
String tmpPath = "tmpPath";
String finalPath = "finalPath";
target = new DataSegmentAndIndexZipFilePath(
SEGMENT,
tmpPath,
finalPath
);

Assert.assertEquals(target, target);
EqualsVerifier.forClass(DataSegmentAndIndexZipFilePath.class).usingGetClass().verify();
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ name: Error Prone Annotations
license_category: binary
module: java-core
license_name: Apache License version 2.0
version: 2.20.0
version: 2.35.1
libraries:
- com.google.errorprone: error_prone_annotations

Expand Down Expand Up @@ -3285,7 +3285,7 @@ name: Checker Qual
license_category: binary
module: java-core
license_name: MIT License
version: 2.5.7
version: 3.48.1
copyright: the Checker Framework developers
license_file_path: licenses/bin/checker-qual.MIT
libraries:
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<datasketches.memory.version>2.2.0</datasketches.memory.version>
<derby.version>10.14.2.0</derby.version>
<dropwizard.metrics.version>4.2.22</dropwizard.metrics.version>
<errorprone.version>2.20.0</errorprone.version>
<errorprone.version>2.35.1</errorprone.version>
<fastutil.version>8.5.4</fastutil.version>
<guava.version>32.0.1-jre</guava.version>
<guice.version>4.1.0</guice.version>
Expand All @@ -114,19 +114,19 @@
<jna.version>5.13.0</jna.version>
<jna-platform.version>5.13.0</jna-platform.version>
<hadoop.compile.version>3.3.6</hadoop.compile.version>
<mockito.version>5.5.0</mockito.version>
<mockito.version>5.14.2</mockito.version>
<!-- mockito-inline artifact was removed in mockito 5.3 (mockito 5.x is required for Java >17),
however it is required in some cases when running against mockito 4.x (mockito 4.x is required for Java <11.
We use the following property to pick the proper artifact based on Java version (see pre-java-11 profile) -->
<mockito.inline.artifact>core</mockito.inline.artifact>
<aws.sdk.version>1.12.638</aws.sdk.version>
<caffeine.version>2.8.0</caffeine.version>
<jacoco.version>0.8.7</jacoco.version>
<jacoco.version>0.8.12</jacoco.version>
<hibernate-validator.version>6.2.5.Final</hibernate-validator.version>
<httpclient.version>4.5.13</httpclient.version>
<!-- When upgrading ZK, edit docs and integration tests as well (integration-tests/docker-base/setup.sh) -->
<zookeeper.version>3.8.4</zookeeper.version>
<checkerframework.version>2.5.7</checkerframework.version>
<checkerframework.version>3.48.1</checkerframework.version>
<com.google.apis.client.version>2.2.0</com.google.apis.client.version>
<com.google.http.client.apis.version>1.42.3</com.google.http.client.apis.version>
<com.google.apis.compute.version>v1-rev20230606-2.0.0</com.google.apis.compute.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ public boolean equals(Object o)
if (this == o) {
return true;
}
if (!(o instanceof ScanOperatorFactory)) {
if (o == null || getClass() != o.getClass()) {
return false;
}
ScanOperatorFactory that = (ScanOperatorFactory) o;
return Objects.equals(offsetLimit, that.offsetLimit)
&& Objects.equals(timeRange, that.timeRange)
&& Objects.equals(filter, that.filter)
&& Objects.equals(projectedColumns, that.projectedColumns)
&& Objects.equals(virtualColumns, that.virtualColumns)
&& Objects.equals(ordering, that.ordering);
return Objects.equals(timeRange, that.timeRange)
&& Objects.equals(filter, that.filter)
&& Objects.equals(offsetLimit, that.offsetLimit)
&& Objects.equals(projectedColumns, that.projectedColumns)
&& Objects.equals(virtualColumns, that.virtualColumns)
&& Objects.equals(ordering, that.ordering);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void testDelta() throws InterruptedException
}

long delta = collector.calculateDelta();
Assert.assertNotNull(delta);
Assert.assertTrue(delta > 0);
log.info("First delta: %s", delta);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@

package org.apache.druid.java.util.metrics;

import org.junit.Assert;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;

public class JvmPidDiscovererTest
{
@Test
public void getPid()
{
Assert.assertNotNull(JvmPidDiscoverer.instance().getPid());
MatcherAssert.assertThat(
JvmPidDiscoverer.instance().getPid(),
Matchers.greaterThan(0L)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.databind.InjectableValues;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableSet;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.common.config.NullHandling;
import org.apache.druid.jackson.DefaultObjectMapper;
import org.apache.druid.java.util.common.Intervals;
Expand Down Expand Up @@ -58,24 +59,7 @@ public class ScanOperatorFactoryTest
@Test
public void testEquals()
{
final Builder bob = new Builder();
bob.timeRange = Intervals.utc(0, 6);
bob.filter = DimFilters.dimEquals("abc", "b");
bob.offsetLimit = OffsetLimit.limit(48);
bob.projectedColumns = Arrays.asList("a", "b");
bob.virtualColumns = VirtualColumns.EMPTY;
bob.ordering = Collections.singletonList(ColumnWithDirection.ascending("a"));
ScanOperatorFactory factory = bob.build();

Assert.assertEquals(factory, factory);
Assert.assertNotEquals(factory, new Object());

Assert.assertNotEquals(factory, bob.copy().setTimeRange(null).build());
Assert.assertNotEquals(factory, bob.copy().setFilter(null).build());
Assert.assertNotEquals(factory, bob.copy().setOffsetLimit(null).build());
Assert.assertNotEquals(factory, bob.copy().setProjectedColumns(null).build());
Assert.assertNotEquals(factory, bob.copy().setVirtualColumns(null).build());
Assert.assertNotEquals(factory, bob.copy().setOrdering(null).build());
EqualsVerifier.forClass(ScanOperatorFactory.class).usingGetClass().verify();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Longs;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.apache.druid.query.dimension.DefaultDimensionSpec;
import org.apache.druid.query.dimension.DimensionSpec;
import org.apache.druid.query.dimension.ExtractionDimensionSpec;
Expand Down Expand Up @@ -395,26 +396,16 @@ public void testGetCacheKey()
@Test
public void testEqualsAndHashCode()
{
final VirtualColumns virtualColumns = VirtualColumns.create(
ImmutableList.of(
new ExpressionVirtualColumn("expr", "x + y", ColumnType.FLOAT, TestExprMacroTable.INSTANCE)
)
);

final VirtualColumns virtualColumns2 = VirtualColumns.create(
ImmutableList.of(
new ExpressionVirtualColumn("expr", "x + y", ColumnType.FLOAT, TestExprMacroTable.INSTANCE)
)
);

Assert.assertEquals(virtualColumns, virtualColumns);
Assert.assertEquals(virtualColumns, virtualColumns2);
Assert.assertNotEquals(VirtualColumns.EMPTY, virtualColumns);
Assert.assertNotEquals(VirtualColumns.EMPTY, null);

Assert.assertEquals(virtualColumns.hashCode(), virtualColumns.hashCode());
Assert.assertEquals(virtualColumns.hashCode(), virtualColumns2.hashCode());
Assert.assertNotEquals(VirtualColumns.EMPTY.hashCode(), virtualColumns.hashCode());
EqualsVerifier.forClass(VirtualColumns.class)
.usingGetClass()
.withIgnoredFields(
"virtualColumnNames",
"equivalence",
"withDotSupport",
"withoutDotSupport",
"hasNoDotColumns"
)
.verify();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class TableMetadataTest
public void testId()
{
TableId id1 = new TableId("schema", "table");
assertEquals(id1, id1);
assertEquals("schema", id1.schema());
assertEquals("table", id1.name());
assertEquals("\"schema\".\"table\"", id1.sqlName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,6 @@ public void testExtendedCharacters() throws SQLException
),
rows
);
Assert.assertEquals(rows, rows);
}
}

Expand Down

0 comments on commit 446a8f4

Please sign in to comment.