Skip to content

Commit 23e2398

Browse files
authored
Fix GCP IO tests on Java 21 (#39295)
1 parent 09af958 commit 23e2398

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

sdks/java/io/google-cloud-platform/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ applyJavaNature(
3030
description = "Apache Beam :: SDKs :: Java :: IO :: Google Cloud Platform"
3131
ext.summary = "IO library to read and write Google Cloud Platform systems from Beam."
3232

33+
tasks.withType(Test).configureEach {
34+
// Open java.nio for Apache Arrow direct memory access under Java 17+
35+
jvmArgs '--add-opens=java.base/java.nio=ALL-UNNAMED'
36+
}
37+
3338
dependencies {
3439
implementation(enforcedPlatform(library.java.google_cloud_platform_libraries_bom))
3540
implementation project(path: ":model:pipeline", configuration: "shadow")

sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BeamRowToStorageApiProtoTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
/** Unit tests form {@link BeamRowToStorageApiProto}. */
6363
@RunWith(JUnit4.class)
6464
public class BeamRowToStorageApiProtoTest {
65+
private static final LocalTime TEST_TIME_MICROS = LocalTime.of(12, 30, 45, 123_456_000);
66+
private static final LocalDateTime TEST_DATETIME_MICROS =
67+
LocalDateTime.of(2024, 1, 15, 12, 30, 45, 123_456_000);
68+
private static final java.time.Instant TEST_INSTANT_MICROS =
69+
java.time.Instant.parse("2024-01-15T12:30:45.123456Z");
6570
private static final java.time.Instant TEST_INSTANT_NANOS =
6671
java.time.Instant.parse("2024-01-15T12:30:45.123456789Z");
6772

@@ -254,9 +259,9 @@ public class BeamRowToStorageApiProtoTest {
254259
.withFieldValue("arrayNullValue", null)
255260
.withFieldValue("iterableValue", ImmutableList.of("blue", "red", "two", "one"))
256261
.withFieldValue("sqlDateValue", LocalDate.now(ZoneOffset.UTC))
257-
.withFieldValue("sqlTimeValue", LocalTime.now(ZoneOffset.UTC))
258-
.withFieldValue("sqlDatetimeValue", LocalDateTime.now(ZoneOffset.UTC))
259-
.withFieldValue("sqlTimestampValue", java.time.Instant.now().plus(123, ChronoUnit.MICROS))
262+
.withFieldValue("sqlTimeValue", TEST_TIME_MICROS)
263+
.withFieldValue("sqlDatetimeValue", TEST_DATETIME_MICROS)
264+
.withFieldValue("sqlTimestampValue", TEST_INSTANT_MICROS)
260265
.withFieldValue("enumValue", TEST_ENUM.valueOf("RED"))
261266
.build();
262267
private static final Map<String, Object> BASE_PROTO_EXPECTED_FIELDS =

0 commit comments

Comments
 (0)