Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ PreCommit Jobs run in a schedule and also get triggered in a PR if relevant sour
| [ PreCommit RAT ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_RAT.yml) | N/A | `Run RAT PreCommit` | [![.github/workflows/beam_PreCommit_RAT.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_RAT.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_RAT.yml?query=event%3Aschedule) |
| [ PreCommit Spotless ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Spotless.yml) | N/A | `Run Spotless PreCommit` | [![.github/workflows/beam_PreCommit_Spotless.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Spotless.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Spotless.yml?query=event%3Aschedule) |
| [ PreCommit SQL ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL.yml) | N/A |`Run SQL PreCommit`| [![.github/workflows/beam_PreCommit_SQL.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL.yml?query=event%3Aschedule) |
| [ PreCommit SQL Java8 ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java8.yml) | N/A |`Run SQL_Java8 PreCommit`| [![.github/workflows/beam_PreCommit_SQL_Java8.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java8.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java8.yml?query=event%3Aschedule) |
| [ PreCommit SQL Java17 ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java17.yml) | N/A |`Run SQL_Java17 PreCommit`| [![.github/workflows/beam_PreCommit_SQL_Java17.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java17.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_SQL_Java17.yml?query=event%3Aschedule) |
| [ PreCommit Typescript ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Typescript.yml) | N/A |`Run Typescript PreCommit`| [![.github/workflows/beam_PreCommit_Typescript.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Typescript.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Typescript.yml?query=event%3Aschedule) |
| [ PreCommit Website ](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Website.yml) | N/A |`Run Website PreCommit`| [![.github/workflows/beam_PreCommit_Website.yml](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Website.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PreCommit_Website.yml?query=event%3Aschedule) |
Expand Down Expand Up @@ -368,9 +367,7 @@ PostCommit Jobs run in a schedule against master branch and generally do not get
| [ PostCommit Java ValidatesRunner Dataflow ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Dataflow.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Dataflow.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Dataflow.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Dataflow.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Dataflow.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Direct JavaVersions ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct_JavaVersions.yml) | ['8','25'] |`beam_PostCommit_Java_ValidatesRunner_Direct_JavaVersions.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Direct_JavaVersions.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct_JavaVersions.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct_JavaVersions.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Direct ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Direct.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Direct.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Direct.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Flink Java8 ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Flink_Java8.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink_Java8.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Flink ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Flink.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Flink.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Flink.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Spark Java8 ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Spark_Java8.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark_Java8.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Spark ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Spark.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Spark.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Spark.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner SparkStructuredStreaming ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_SparkStructuredStreaming.yml?query=event%3Aschedule) |
| [ PostCommit Java ValidatesRunner Twister2 ](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Twister2.yml) | N/A |`beam_PostCommit_Java_ValidatesRunner_Twister2.json`| [![.github/workflows/beam_PostCommit_Java_ValidatesRunner_Twister2.yml](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Twister2.yml/badge.svg?event=schedule)](https://github.com/apache/beam/actions/workflows/beam_PostCommit_Java_ValidatesRunner_Twister2.yml?query=event%3Aschedule) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ class BeamModulePlugin implements Plugin<Project> {
aircompressor : "io.airlift:aircompressor:2.0.3",
args4j : "args4j:args4j:2.33",
auto_value_annotations : "com.google.auto.value:auto-value-annotations:$autovalue_version",
// TODO: https://github.com/apache/beam/issues/34993 after stopping supporting Java 8
avro : "org.apache.avro:avro:1.11.4",
// TODO: upgrade post 1.12.1 once https://issues.apache.org/jira/browse/AVRO-4209 resolved
avro : "org.apache.avro:avro:1.12.0",
aws_java_sdk2_apache_client : "software.amazon.awssdk:apache-client:$aws_java_sdk2_version",
aws_java_sdk2_netty_client : "software.amazon.awssdk:netty-nio-client:$aws_java_sdk2_version",
aws_java_sdk2_auth : "software.amazon.awssdk:auth:$aws_java_sdk2_version",
Expand Down
4 changes: 2 additions & 2 deletions sdks/java/extensions/avro/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def avroVersions = [
'182' : "1.8.2",
'192' : "1.9.2",
'1102': "1.10.2",
'1120': "1.12.0",
'1113': "1.11.3",
]

avroVersions.each { k, v ->
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
// Exclude Avro dependencies from "core" since Avro support moved to this extension
exclude group: "org.apache.avro", module: "avro"
}
testImplementation project(path: ":sdks:java:extensions:avro:vendored-test", configuration: "shadowTest")
testImplementation(library.java.avro + ':tests')
testImplementation library.java.junit
testImplementation "org.tukaani:xz:1.9" // marked as optional in avro
testImplementation "com.esotericsoftware:kryo:5.6.2" // Used by Avro coder test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
"rawtypes"
})
public class AvroUtils {
public static final String VERSION_AVRO =
org.apache.avro.Schema.class.getPackage().getImplementationVersion();
Comment on lines +159 to +160
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The getImplementationVersion() method can return null if the manifest information is not available (e.g., when running tests in certain IDEs or environments). Since VERSION_AVRO is used in comparisons like VERSION_AVRO.equals("1.8.2") in other classes (e.g., TestAvroConversionFactory), this could lead to a NullPointerException. It is safer to handle the null case here by providing a default value like an empty string.

Suggested change
public static final String VERSION_AVRO =
org.apache.avro.Schema.class.getPackage().getImplementationVersion();
public static final String VERSION_AVRO =
java.util.Optional.ofNullable(org.apache.avro.Schema.class.getPackage())
.map(java.lang.Package::getImplementationVersion)
.orElse("");

private static final ForLoadedType BYTES = new ForLoadedType(byte[].class);
private static final ForLoadedType JAVA_INSTANT = new ForLoadedType(java.time.Instant.class);
private static final ForLoadedType JAVA_LOCALE_DATE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
package org.apache.beam.sdk.extensions.avro;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import static org.junit.Assert.assertEquals;

import org.apache.avro.Schema;
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Strings;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.Assume;
Expand All @@ -33,7 +33,6 @@ public class AvroVersionVerificationTest {
public void testAvroVersion() {
@Nullable String targetVer = System.getProperty("beam.target.avro.version");
Assume.assumeTrue(!Strings.isNullOrEmpty(targetVer));
String actualVer = Schema.class.getPackage().getImplementationVersion();
assertEquals(targetVer, actualVer);
assertEquals(targetVer, VERSION_AVRO);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.beam.sdk.extensions.avro.coders;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand Down Expand Up @@ -131,8 +132,6 @@ public class AvroCoderTest {
ImmutableList.of(AVRO_NESTED_SPECIFIC_RECORD, AVRO_NESTED_SPECIFIC_RECORD),
ImmutableMap.of("k1", AVRO_NESTED_SPECIFIC_RECORD, "k2", AVRO_NESTED_SPECIFIC_RECORD));

private static final String VERSION_AVRO = Schema.class.getPackage().getImplementationVersion();

@DefaultCoder(AvroCoder.class)
private static class Pojo {
public String text;
Expand Down Expand Up @@ -875,6 +874,7 @@ private static class StringableClass {}

@Test
public void testDeterminismCyclicClass() {
// Note: this test fails on Avro 1.12.1 due to https://issues.apache.org/jira/browse/AVRO-4209
assertNonDeterministic(
AvroCoder.of(Cyclic.class),
reasonField(Cyclic.class, "cyclicField", "appears recursively"));
Expand Down Expand Up @@ -1164,6 +1164,7 @@ private static class NullableCyclicField {

@Test
public void testNullableNonDeterministicField() {
// Note: this test fails on Avro 1.12.1 due to https://issues.apache.org/jira/browse/AVRO-4209
assertNonDeterministic(
AvroCoder.of(NullableCyclic.class),
reasonField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
*/
package org.apache.beam.sdk.extensions.avro.io;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;

import java.lang.reflect.Constructor;
import org.apache.avro.Schema;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Create a {@link AvroGeneratedUser} instance with different constructors. */
public class AvroGeneratedUserFactory {
private static final Logger LOG = LoggerFactory.getLogger(AvroGeneratedUserFactory.class);
private static final String VERSION_AVRO = Schema.class.getPackage().getImplementationVersion();

public static AvroGeneratedUser newInstance(
String name, Integer favoriteNumber, String favoriteColor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.beam.sdk.extensions.avro.io;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The Schema class is used in the updated readString method signature later in this file (lines 563 and 565), but it is not imported. This will cause a compilation error. Adding the import here resolves the issue.

Suggested change
import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import org.apache.avro.Schema;

import static org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
Expand Down Expand Up @@ -74,9 +75,6 @@
/** Tests for AvroSource. */
@RunWith(JUnit4.class)
public class AvroSourceTest {
private static final String VERSION_AVRO =
org.apache.avro.Schema.class.getPackage().getImplementationVersion();

@Rule public TemporaryFolder tmpFolder = new TemporaryFolder();

@Rule public ExpectedException expectedException = ExpectedException.none();
Expand Down Expand Up @@ -560,10 +558,11 @@ public void testDatumReaderFactoryWithGenericRecord() throws Exception {

AvroSource.DatumReaderFactory<GenericRecord> factory =
(writer, reader) ->
new GenericDatumReader<GenericRecord>(writer, reader) {
new GenericDatumReader<>(writer, reader) {
@Override
protected Object readString(Object old, Decoder in) throws IOException {
return super.readString(old, in) + "_custom";
protected Object readString(Object old, Schema schema, Decoder in)
throws IOException {
return super.readString(old, schema, in) + "_custom";
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.apache.avro.file.DataFileConstants.NULL_CODEC;
import static org.apache.avro.file.DataFileConstants.SNAPPY_CODEC;
import static org.apache.avro.file.DataFileConstants.XZ_CODEC;
import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
Expand All @@ -40,9 +41,6 @@
/** Tests of SerializableAvroCodecFactory. */
@RunWith(JUnit4.class)
public class SerializableAvroCodecFactoryTest {
private static final String VERSION_AVRO =
org.apache.avro.Schema.class.getPackage().getImplementationVersion();

private static final List<String> avroCodecs = new ArrayList<>();

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
*/
package org.apache.beam.sdk.extensions.avro.schemas;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;

import java.lang.reflect.Constructor;
import org.apache.avro.Schema;
import org.joda.time.LocalDate;

/** Create a {@link TestAvroConversion} instance with different constructors. */
public class TestAvroConversionFactory {

private static final String VERSION_AVRO = Schema.class.getPackage().getImplementationVersion();

public static TestAvroConversion newInstance(LocalDate date) throws Exception {
if (VERSION_AVRO.equals("1.8.2")) {
Constructor<?> constructor = TestAvroConversion.class.getDeclaredConstructor(LocalDate.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/
package org.apache.beam.sdk.extensions.avro.schemas;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;

import java.lang.reflect.Constructor;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import org.apache.avro.Schema;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
import org.slf4j.Logger;
Expand All @@ -30,7 +31,6 @@
/** Create a {@link TestAvro} instance with different constructors. */
public class TestAvroFactory {
private static final Logger LOG = LoggerFactory.getLogger(TestAvroFactory.class);
private static final String VERSION_AVRO = Schema.class.getPackage().getImplementationVersion();

public static TestAvro newInstance(
Boolean boolNonNullable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.beam.sdk.extensions.avro.schemas.utils;

import static org.apache.beam.sdk.extensions.avro.schemas.utils.AvroUtils.VERSION_AVRO;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -86,9 +87,6 @@ public class AvroUtilsTest {
private static final org.apache.avro.Schema NULL_SCHEMA =
org.apache.avro.Schema.create(org.apache.avro.Schema.Type.NULL);

private static final String VERSION_AVRO =
org.apache.avro.Schema.class.getPackage().getImplementationVersion();

private Iterable<?> randomData(org.apache.avro.Schema schema, int maxLength) throws Exception {
Iterable<?> data;
if (VERSION_AVRO.equals("1.8.2")) {
Expand Down
38 changes: 0 additions & 38 deletions sdks/java/extensions/avro/vendored-test/build.gradle

This file was deleted.

2 changes: 0 additions & 2 deletions sdks/java/io/expansion-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ applyJavaNature(
configurations.runtimeClasspath {
// Pin kafka-clients version due to <3.4.0 missing auth callback classes.
resolutionStrategy.force 'org.apache.kafka:kafka-clients:3.9.0'
// iceberg needs avro:1.12.0
resolutionStrategy.force 'org.apache.avro:avro:1.12.0'
// force parquet-avro:1.15.2 to fix CVE-2025-46762
resolutionStrategy.force 'org.apache.parquet:parquet-avro:1.15.2'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ applyJavaNature(
shadowClosure: {},
)

configurations.runtimeClasspath {
// Pin avro to 1.11.4 due to https://github.com/apache/beam/issues/34968
// cannot upgrade this to the latest version due to https://github.com/apache/beam/issues/34993
resolutionStrategy.force 'org.apache.avro:avro:1.11.4'
}

description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform :: Expansion Service"
ext.summary = "Expansion service serving GCP Java IOs"

Expand Down
Loading
Loading