diff --git a/api/src/test/java/org/apache/iceberg/io/TestCloseableIterable.java b/api/src/test/java/org/apache/iceberg/io/TestCloseableIterable.java index 0c001c53180b..bed414d3cb54 100644 --- a/api/src/test/java/org/apache/iceberg/io/TestCloseableIterable.java +++ b/api/src/test/java/org/apache/iceberg/io/TestCloseableIterable.java @@ -195,10 +195,11 @@ public CloseableIterator iterator() { } }); + AtomicInteger consumedCounter = new AtomicInteger(0); try (CloseableIterable concat = CloseableIterable.concat(transform)) { - concat.forEach(c -> c++); + concat.forEach(count -> consumedCounter.getAndIncrement()); } - Assertions.assertThat(counter.get()).isEqualTo(items.size()); + Assertions.assertThat(counter.get()).isEqualTo(items.size()).isEqualTo(consumedCounter.get()); } @Test diff --git a/baseline.gradle b/baseline.gradle index 6d5ce07caf31..04fad576c10d 100644 --- a/baseline.gradle +++ b/baseline.gradle @@ -42,6 +42,15 @@ subprojects { apply plugin: 'com.palantir.baseline-release-compatibility' apply plugin: 'com.diffplug.spotless' + pluginManager.withPlugin('com.palantir.baseline-checkstyle') { + checkstyle { + // com.palantir.baseline:gradle-baseline-java:4.42.0 (the last version supporting Java 8) pulls + // in an old version of the checkstyle(9.1), which has this OutOfMemory bug https://github.com/checkstyle/checkstyle/issues/10934. + // So, override its checkstyle version using CheckstyleExtension to 9.3 (the latest java 8 supported version) which contains a fix. + toolVersion '9.3' + } + } + pluginManager.withPlugin('com.diffplug.spotless') { spotless { java { diff --git a/build.gradle b/build.gradle index 2919308d8c9b..977a1b96fd91 100644 --- a/build.gradle +++ b/build.gradle @@ -32,10 +32,6 @@ buildscript { // in an old version of the errorprone, which doesn't work w/ Gradle 8, so bump errorpone as // well. classpath "net.ltgt.gradle:gradle-errorprone-plugin:3.0.1" - // com.palantir.baseline:gradle-baseline-java:4.42.0 (the last version supporting Java 8) pulls - // in an old version of the checkstyle(9.1), which has this OutOfMemory bug https://github.com/checkstyle/checkstyle/issues/10934 - // So, bump checkstyle to the latest java 8 supported version(9.3) which contains the fix. - classpath "com.puppycrawl.tools:checkstyle:9.3" classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.13.0' classpath 'gradle.plugin.org.inferred:gradle-processors:3.7.0' diff --git a/core/src/test/java/org/apache/iceberg/TestMetrics.java b/core/src/test/java/org/apache/iceberg/TestMetrics.java index 7eb4d3344326..32bc6299ce1b 100644 --- a/core/src/test/java/org/apache/iceberg/TestMetrics.java +++ b/core/src/test/java/org/apache/iceberg/TestMetrics.java @@ -454,7 +454,7 @@ public void testMetricsForTopLevelWithMultipleRowGroup() throws Exception { for (int i = 0; i < recordCount; i++) { Record newRecord = GenericRecord.create(SIMPLE_SCHEMA); - newRecord.setField("booleanCol", i == 0 ? false : true); + newRecord.setField("booleanCol", i != 0); newRecord.setField("intCol", i + 1); newRecord.setField("longCol", i == 0 ? null : i + 1L); newRecord.setField("floatCol", i + 1.0F); diff --git a/flink/v1.15/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java b/flink/v1.15/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java index 367afb75f920..1363c152e07c 100644 --- a/flink/v1.15/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java +++ b/flink/v1.15/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java @@ -113,6 +113,7 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( schemaConvertedFromIceberg.getFields().stream() .map( field -> { + org.apache.avro.Schema.Field updatedField = field; if (field.name().equals("time_field")) { // Iceberg's AvroSchemaUtil uses timestamp-micros with Long value for time // field, while AvroToRowDataConverters#convertToTime() always looks for @@ -124,10 +125,10 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( LogicalTypes.timeMillis() .addToSchema( org.apache.avro.Schema.create(org.apache.avro.Schema.Type.INT)); - field = new org.apache.avro.Schema.Field("time_field", fieldSchema); + updatedField = new org.apache.avro.Schema.Field("time_field", fieldSchema); } - return new org.apache.avro.Schema.Field(field, field.schema()); + return new org.apache.avro.Schema.Field(updatedField, updatedField.schema()); }) .collect(Collectors.toList()); return org.apache.avro.Schema.createRecord( diff --git a/flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java b/flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java index 367afb75f920..1363c152e07c 100644 --- a/flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java +++ b/flink/v1.16/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java @@ -113,6 +113,7 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( schemaConvertedFromIceberg.getFields().stream() .map( field -> { + org.apache.avro.Schema.Field updatedField = field; if (field.name().equals("time_field")) { // Iceberg's AvroSchemaUtil uses timestamp-micros with Long value for time // field, while AvroToRowDataConverters#convertToTime() always looks for @@ -124,10 +125,10 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( LogicalTypes.timeMillis() .addToSchema( org.apache.avro.Schema.create(org.apache.avro.Schema.Type.INT)); - field = new org.apache.avro.Schema.Field("time_field", fieldSchema); + updatedField = new org.apache.avro.Schema.Field("time_field", fieldSchema); } - return new org.apache.avro.Schema.Field(field, field.schema()); + return new org.apache.avro.Schema.Field(updatedField, updatedField.schema()); }) .collect(Collectors.toList()); return org.apache.avro.Schema.createRecord( diff --git a/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java b/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java index 367afb75f920..1363c152e07c 100644 --- a/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java +++ b/flink/v1.17/flink/src/test/java/org/apache/iceberg/flink/DataGenerators.java @@ -113,6 +113,7 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( schemaConvertedFromIceberg.getFields().stream() .map( field -> { + org.apache.avro.Schema.Field updatedField = field; if (field.name().equals("time_field")) { // Iceberg's AvroSchemaUtil uses timestamp-micros with Long value for time // field, while AvroToRowDataConverters#convertToTime() always looks for @@ -124,10 +125,10 @@ private org.apache.avro.Schema fixupAvroSchemaConvertedFromIcebergSchema( LogicalTypes.timeMillis() .addToSchema( org.apache.avro.Schema.create(org.apache.avro.Schema.Type.INT)); - field = new org.apache.avro.Schema.Field("time_field", fieldSchema); + updatedField = new org.apache.avro.Schema.Field("time_field", fieldSchema); } - return new org.apache.avro.Schema.Field(field, field.schema()); + return new org.apache.avro.Schema.Field(updatedField, updatedField.schema()); }) .collect(Collectors.toList()); return org.apache.avro.Schema.createRecord( diff --git a/parquet/src/test/java/org/apache/iceberg/parquet/TestBloomRowGroupFilter.java b/parquet/src/test/java/org/apache/iceberg/parquet/TestBloomRowGroupFilter.java index e3e938e45034..34a92a9b4483 100644 --- a/parquet/src/test/java/org/apache/iceberg/parquet/TestBloomRowGroupFilter.java +++ b/parquet/src/test/java/org/apache/iceberg/parquet/TestBloomRowGroupFilter.java @@ -248,7 +248,7 @@ public void createInputFile() throws IOException { structNotNull.put("_int_field", INT_MIN_VALUE + i); builder.set("_struct_not_null", structNotNull); // struct with int builder.set("_no_stats", TOO_LONG_FOR_STATS); // value longer than 4k will produce no stats - builder.set("_boolean", (i % 2 == 0) ? true : false); + builder.set("_boolean", i % 2 == 0); builder.set("_time", instant.plusSeconds(i * 86400).toEpochMilli()); builder.set("_date", instant.plusSeconds(i * 86400).getEpochSecond()); builder.set("_timestamp", instant.plusSeconds(i * 86400).toEpochMilli()); diff --git a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java index 7bbfc3138678..e5831b76e424 100644 --- a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java +++ b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java @@ -140,7 +140,7 @@ public void writeTestDataFile() throws IOException { "id_string", BINARY_PREFIX + (INT_MIN_VALUE + i), "id_boolean", - (i % 2 == 0) ? true : false, + i % 2 == 0, "id_date", LocalDate.parse("2021-09-05"), "id_int_decimal", diff --git a/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java b/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java index 7bbfc3138678..e5831b76e424 100644 --- a/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java +++ b/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkReaderWithBloomFilter.java @@ -140,7 +140,7 @@ public void writeTestDataFile() throws IOException { "id_string", BINARY_PREFIX + (INT_MIN_VALUE + i), "id_boolean", - (i % 2 == 0) ? true : false, + i % 2 == 0, "id_date", LocalDate.parse("2021-09-05"), "id_int_decimal",