From be64a842fcc573165aeb77c1f0bb1d7118c29199 Mon Sep 17 00:00:00 2001 From: dragonHead1001001 Date: Sun, 11 Aug 2024 15:22:39 +0530 Subject: [PATCH 1/5] [Task]: Replace JacksonFactory references with GsonFactory #32130 --- gradle/wrapper/gradle-wrapper.properties | 5 ++--- .../apache/beam/sdk/extensions/gcp/util/Transport.java | 3 ++- .../beam/sdk/extensions/gcp/util/GcsUtilTest.java | 10 +++++----- .../LatencyRecordingHttpRequestInitializerTest.java | 4 ++-- .../gcp/util/RetryHttpRequestInitializerTest.java | 4 ++-- .../sdk/io/gcp/healthcare/HttpHealthcareApiClient.java | 3 +-- .../sdk/io/gcp/bigquery/BigQueryServicesImplTest.java | 6 +++--- .../beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java | 4 ++-- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3fa8f862f753..086e52fca019 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ +#Sat Aug 10 17:06:24 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java index ac6d825e125d..180f32c3228f 100644 --- a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java +++ b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java @@ -23,6 +23,7 @@ import com.google.api.client.http.HttpRequestInitializer; import com.google.api.client.http.HttpTransport; import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.storage.Storage; import com.google.auth.Credentials; @@ -53,7 +54,7 @@ private static class SingletonHelper { static { try { - JSON_FACTORY = JacksonFactory.getDefaultInstance(); + JSON_FACTORY = GsonFactory.getDefaultInstance(); HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); } catch (GeneralSecurityException | IOException e) { throw new RuntimeException(e); diff --git a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilTest.java b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilTest.java index 1d35cb0d04d4..bd7f46ec8951 100644 --- a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilTest.java +++ b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/GcsUtilTest.java @@ -49,7 +49,7 @@ import com.google.api.client.json.GenericJson; import com.google.api.client.json.Json; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.testing.http.HttpTesting; import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; @@ -474,7 +474,7 @@ public void testRetryFileSizeNonBatch() throws IOException { @Test public void testGetSizeBytesWhenFileNotFoundBatch() throws Exception { - JsonFactory jsonFactory = new JacksonFactory(); + JsonFactory jsonFactory = new GsonFactory(); String contentBoundary = "batch_foobarbaz"; String contentBoundaryLine = "--" + contentBoundary; @@ -545,7 +545,7 @@ public void testGetSizeBytesWhenFileNotFoundNoBatch() throws Exception { @Test public void testGetSizeBytesWhenFileNotFoundBatchRetry() throws Exception { - JsonFactory jsonFactory = new JacksonFactory(); + JsonFactory jsonFactory = new GsonFactory(); String contentBoundary = "batch_foobarbaz"; String contentBoundaryLine = "--" + contentBoundary; @@ -657,7 +657,7 @@ public LowLevelHttpResponse execute() throws IOException { @Test public void testRemoveWhenFileNotFound() throws Exception { - JsonFactory jsonFactory = new JacksonFactory(); + JsonFactory jsonFactory = new GsonFactory(); String contentBoundary = "batch_foobarbaz"; String contentBoundaryLine = "--" + contentBoundary; @@ -1045,7 +1045,7 @@ private void verifyMetricWasSet( /** Builds a fake GoogleJsonResponseException for testing API error handling. */ private static GoogleJsonResponseException googleJsonResponseException( final int status, final String reason, final String message) throws IOException { - final JsonFactory jsonFactory = new JacksonFactory(); + final JsonFactory jsonFactory = new GsonFactory(); HttpTransport transport = new MockHttpTransport() { @Override diff --git a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/LatencyRecordingHttpRequestInitializerTest.java b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/LatencyRecordingHttpRequestInitializerTest.java index 6e0b45df141d..c2f3d063f4c9 100644 --- a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/LatencyRecordingHttpRequestInitializerTest.java +++ b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/LatencyRecordingHttpRequestInitializerTest.java @@ -34,7 +34,7 @@ import com.google.api.client.http.LowLevelHttpRequest; import com.google.api.client.http.LowLevelHttpResponse; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.storage.Storage; import java.io.IOException; import org.apache.beam.sdk.metrics.Histogram; @@ -61,7 +61,7 @@ public class LatencyRecordingHttpRequestInitializerTest { @Mock private LowLevelHttpResponse mockLowLevelResponse; @Mock private Histogram mockHistogram; - private final JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); + private final JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); private Storage storage; @Before diff --git a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/RetryHttpRequestInitializerTest.java b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/RetryHttpRequestInitializerTest.java index a604b97cd35a..46929d1b6e7a 100644 --- a/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/RetryHttpRequestInitializerTest.java +++ b/sdks/java/extensions/google-cloud-platform-core/src/test/java/org/apache/beam/sdk/extensions/gcp/util/RetryHttpRequestInitializerTest.java @@ -39,7 +39,7 @@ import com.google.api.client.http.LowLevelHttpRequest; import com.google.api.client.http.LowLevelHttpResponse; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; import com.google.api.client.testing.http.MockLowLevelHttpResponse; @@ -79,7 +79,7 @@ public class RetryHttpRequestInitializerTest { @Mock private LowLevelHttpResponse mockLowLevelResponse; @Mock private HttpResponseInterceptor mockHttpResponseInterceptor; - private final JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); + private final JsonFactory jsonFactory = GsonFactory.getDefaultInstance(); private Storage storage; // Used to test retrying a request more than the default 10 times. diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java index 9a2a16bd949c..7d99043cde73 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java @@ -24,7 +24,6 @@ import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.gson.GsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.healthcare.v1.CloudHealthcare; import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores.Fhir.PatientEverything; import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.Hl7V2Stores.Messages; @@ -736,7 +735,7 @@ private void initClient() throws IOException { client = new CloudHealthcare.Builder( - new NetHttpTransport(), new JacksonFactory(), requestInitializer) + new NetHttpTransport(), new GsonFactory(), requestInitializer) .setApplicationName("apache-beam-hl7v2-io") .build(); httpClient = diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java index 5fac8f1a1b4e..4da9d4eb6a70 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryServicesImplTest.java @@ -45,7 +45,7 @@ import com.google.api.client.http.LowLevelHttpResponse; import com.google.api.client.json.GenericJson; import com.google.api.client.json.Json; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; import com.google.api.client.testing.util.MockSleeper; @@ -1597,12 +1597,12 @@ public void testSkipInvalidRowsIgnoreUnknownIgnoreInsertIdsValuesStreaming() /** A helper to convert a string response back to a {@link GenericJson} subclass. */ private static T fromString(String content, Class clazz) throws IOException { - return JacksonFactory.getDefaultInstance().fromString(content, clazz); + return GsonFactory.getDefaultInstance().fromString(content, clazz); } /** A helper to wrap a {@link GenericJson} object in a content stream. */ private static InputStream toStream(GenericJson content) throws IOException { - return new ByteArrayInputStream(JacksonFactory.getDefaultInstance().toByteArray(content)); + return new ByteArrayInputStream(GsonFactory.getDefaultInstance().toByteArray(content)); } /** A helper that generates the error JSON payload that Google APIs produce. */ diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java index 6bc0fbbbd7c9..90c2a647cd45 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java @@ -20,7 +20,7 @@ import com.google.api.client.http.HttpHeaders; import com.google.api.client.http.HttpRequestInitializer; import com.google.api.client.http.javanet.NetHttpTransport; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.healthcare.v1.model.HttpBody; import com.google.api.services.storage.Storage; import com.google.api.services.storage.model.StorageObject; @@ -136,7 +136,7 @@ public static void tearDownTempBucket() throws IOException { request.setReadTimeout(60000); // 1 minute read timeout }; Storage storage = - new Storage.Builder(new NetHttpTransport(), new JacksonFactory(), requestInitializer) + new Storage.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer) .build(); List blobs = storage.objects().list(DEFAULT_TEMP_BUCKET).execute().getItems(); if (blobs != null) { From ce5a66b623d69c48f470865fbce5f0b52fb4f0d8 Mon Sep 17 00:00:00 2001 From: dragonHead1001001 Date: Mon, 12 Aug 2024 23:52:26 +0530 Subject: [PATCH 2/5] Fixing minor issues due to the replacement of JacksonFcatory with GsonFactory and further updation --- .test-infra/dockerized-jenkins/plugins.txt | 2 +- .../org/apache/beam/gradle/BeamModulePlugin.groovy | 4 ++-- runners/google-cloud-dataflow-java/build.gradle | 4 ++-- .../beam/runners/dataflow/util/PackageUtilTest.java | 4 ++-- .../worker/graph/LengthPrefixUnknownCodersTest.java | 10 +++++----- .../dataflow/worker/testing/GenericJsonAssert.java | 8 ++++---- .../dataflow/worker/testing/GenericJsonMatcher.java | 8 ++++---- .../extensions/google-cloud-platform-core/build.gradle | 2 +- .../apache/beam/sdk/extensions/gcp/util/Transport.java | 1 - sdks/java/io/google-cloud-platform/build.gradle | 2 +- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.test-infra/dockerized-jenkins/plugins.txt b/.test-infra/dockerized-jenkins/plugins.txt index 4ea6ac5acb8d..3c88156a6ed2 100644 --- a/.test-infra/dockerized-jenkins/plugins.txt +++ b/.test-infra/dockerized-jenkins/plugins.txt @@ -54,7 +54,7 @@ github-branch-source gradle handlebars handy-uri-templates-2-api -jackson2-api +gson-api jacoco javadoc jaxb diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy index ee116423e4b0..74b37665e038 100644 --- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy @@ -731,7 +731,7 @@ class BeamModulePlugin implements Plugin { google_ads : "com.google.api-ads:google-ads:$google_ads_version", google_ads_stubs_v14 : "com.google.api-ads:google-ads-stubs-v14:$google_ads_version", google_api_client : "com.google.api-client:google-api-client:$google_clients_version", // for the libraries using $google_clients_version below. - google_api_client_jackson2 : "com.google.api-client:google-api-client-jackson2:$google_clients_version", + google_api_client_gson : "com.google.api-client:google-api-client-gson:$google_clients_version", google_api_client_java6 : "com.google.api-client:google-api-client-java6:$google_clients_version", google_api_common : "com.google.api:api-common", // google_cloud_platform_libraries_bom sets version google_api_services_bigquery : "com.google.apis:google-api-services-bigquery:v2-rev20240323-2.0.0", // [bomupgrader] sets version @@ -768,7 +768,7 @@ class BeamModulePlugin implements Plugin { google_http_client_apache_v2 : "com.google.http-client:google-http-client-apache-v2", // google_cloud_platform_libraries_bom sets version google_http_client_gson : "com.google.http-client:google-http-client-gson", // google_cloud_platform_libraries_bom sets version google_http_client_jackson : "com.google.http-client:google-http-client-jackson:1.29.2", - google_http_client_jackson2 : "com.google.http-client:google-http-client-jackson2", // google_cloud_platform_libraries_bom sets version + google_http_client_gson : "com.google.http-client:google-http-client-gson", // google_cloud_platform_libraries_bom sets version google_http_client_protobuf : "com.google.http-client:google-http-client-protobuf", // google_cloud_platform_libraries_bom sets version google_oauth_client : "com.google.oauth-client:google-oauth-client:$google_oauth_clients_version", google_oauth_client_java6 : "com.google.oauth-client:google-oauth-client-java6:$google_oauth_clients_version", diff --git a/runners/google-cloud-dataflow-java/build.gradle b/runners/google-cloud-dataflow-java/build.gradle index 5d898bb57d86..846d1b99aa52 100644 --- a/runners/google-cloud-dataflow-java/build.gradle +++ b/runners/google-cloud-dataflow-java/build.gradle @@ -108,8 +108,8 @@ dependencies { implementation library.java.google_auth_library_credentials implementation library.java.google_auth_library_oauth2_http implementation library.java.google_http_client - implementation library.java.google_http_client_jackson2 - permitUnusedDeclared library.java.google_http_client_jackson2 // BEAM-11761 + implementation library.java.google_http_client_gson + permitUnusedDeclared library.java.google_http_client_gson // BEAM-11761 implementation library.java.hamcrest implementation library.java.jackson_annotations implementation library.java.jackson_core diff --git a/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java b/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java index f9f68f4e7409..0a59e3f9f9b7 100644 --- a/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java +++ b/runners/google-cloud-dataflow-java/src/test/java/org/apache/beam/runners/dataflow/util/PackageUtilTest.java @@ -44,7 +44,7 @@ import com.google.api.client.json.GenericJson; import com.google.api.client.json.Json; import com.google.api.client.json.JsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.testing.http.HttpTesting; import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; @@ -580,7 +580,7 @@ public void testPackageUploadIsSkippedWithNonExistentResource() throws Exception /** Builds a fake GoogleJsonResponseException for testing API error handling. */ private static GoogleJsonResponseException googleJsonResponseException( final int status, final String reason, final String message) throws IOException { - final JsonFactory jsonFactory = new JacksonFactory(); + final JsonFactory jsonFactory = new GsonFactory(); HttpTransport transport = new MockHttpTransport() { @Override diff --git a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/graph/LengthPrefixUnknownCodersTest.java b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/graph/LengthPrefixUnknownCodersTest.java index 7a87cdac7d65..55cb0636e35d 100644 --- a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/graph/LengthPrefixUnknownCodersTest.java +++ b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/graph/LengthPrefixUnknownCodersTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertNotSame; import com.google.api.client.json.GenericJson; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import com.google.api.services.dataflow.model.InstructionOutput; import com.google.api.services.dataflow.model.ParDoInstruction; import com.google.api.services.dataflow.model.ParallelInstruction; @@ -89,7 +89,7 @@ public class LengthPrefixUnknownCodersTest { public void setup() { MockitoAnnotations.initMocks(this); instruction = new ParallelInstruction(); - instruction.setFactory(new JacksonFactory()); + instruction.setFactory(new GsonFactory()); } /** Test wrapping unknown coders with {@code LengthPrefixCoder} */ @@ -142,7 +142,7 @@ public void testLengthPrefixAndReplaceUnknownCoder() throws Exception { public void testLengthPrefixInstructionOutputCoder() throws Exception { InstructionOutput output = new InstructionOutput(); output.setCodec(CloudObjects.asCloudObject(windowedValueCoder, /*sdkComponents=*/ null)); - output.setFactory(new JacksonFactory()); + output.setFactory(new GsonFactory()); InstructionOutput prefixedOutput = forInstructionOutput(output, false); assertEqualsAsJson( @@ -267,7 +267,7 @@ private static ParallelInstructionNode createReadNode( .setCodec(CloudObjects.asCloudObject(coder, /*sdkComponents=*/ null)) .setSpec(CloudObject.forClassName(readClassName)))); - parallelInstruction.setFactory(new JacksonFactory()); + parallelInstruction.setFactory(new GsonFactory()); return ParallelInstructionNode.create(parallelInstruction, Nodes.ExecutionLocation.UNKNOWN); } @@ -276,7 +276,7 @@ private static InstructionOutputNode createInstructionOutputNode(String name, Co new InstructionOutput() .setName(name) .setCodec(CloudObjects.asCloudObject(coder, /*sdkComponents=*/ null)); - instructionOutput.setFactory(new JacksonFactory()); + instructionOutput.setFactory(new GsonFactory()); return InstructionOutputNode.create(instructionOutput, "fakeId"); } } diff --git a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonAssert.java b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonAssert.java index f4e726851297..332307e2bbca 100644 --- a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonAssert.java +++ b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonAssert.java @@ -18,7 +18,7 @@ package org.apache.beam.runners.dataflow.worker.testing; import com.google.api.client.json.GenericJson; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import java.io.IOException; import org.json.JSONException; import org.skyscreamer.jsonassert.JSONAssert; @@ -26,7 +26,7 @@ /** Assertions on {@link GenericJson} class. */ public class GenericJsonAssert { - private static final JacksonFactory jacksonFactory = JacksonFactory.getDefaultInstance(); + private static final GsonFactory gsonFactory = GsonFactory.getDefaultInstance(); /** * Asserts that {@code actual} has the same JSON representation as {@code expected}. @@ -39,8 +39,8 @@ public static void assertEqualsAsJson(Object expected, Object actual) { try { String expectedJsonText = - expected instanceof String ? (String) expected : jacksonFactory.toString(expected); - String actualJsonText = jacksonFactory.toString(actual); + expected instanceof String ? (String) expected : gsonFactory.toString(expected); + String actualJsonText = gsonFactory.toString(actual); JSONAssert.assertEquals(expectedJsonText, actualJsonText, true); } catch (JSONException ex) { throw new IllegalArgumentException("Could not parse JSON", ex); diff --git a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonMatcher.java b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonMatcher.java index e576a33cd746..7f388d667ac8 100644 --- a/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonMatcher.java +++ b/runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/testing/GenericJsonMatcher.java @@ -18,7 +18,7 @@ package org.apache.beam.runners.dataflow.worker.testing; import com.google.api.client.json.GenericJson; -import com.google.api.client.json.jackson2.JacksonFactory; +import com.google.api.client.json.gson.GsonFactory; import java.io.IOException; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; @@ -35,11 +35,11 @@ public final class GenericJsonMatcher extends TypeSafeMatcher { private String expectedJsonText; - private static final JacksonFactory jacksonFactory = JacksonFactory.getDefaultInstance(); + private static final GsonFactory gsonFactory = GsonFactory.getDefaultInstance(); private GenericJsonMatcher(GenericJson expected) { try { - expectedJsonText = jacksonFactory.toString(expected); + expectedJsonText = gsonFactory.toString(expected); } catch (IOException ex) { throw new IllegalArgumentException("Could not parse JSON", ex); } @@ -52,7 +52,7 @@ public static GenericJsonMatcher jsonOf(GenericJson genericJson) { @Override protected boolean matchesSafely(GenericJson actual) { try { - String actualJsonText = jacksonFactory.toString(actual); + String actualJsonText = gsonFactory.toString(actual); JSONCompareResult result = JSONCompare.compareJSON(expectedJsonText, actualJsonText, JSONCompareMode.STRICT); return result.passed(); diff --git a/sdks/java/extensions/google-cloud-platform-core/build.gradle b/sdks/java/extensions/google-cloud-platform-core/build.gradle index 4af856cc9ff3..6cb8d3248ac1 100644 --- a/sdks/java/extensions/google-cloud-platform-core/build.gradle +++ b/sdks/java/extensions/google-cloud-platform-core/build.gradle @@ -39,7 +39,7 @@ dependencies { implementation library.java.vendored_guava_32_1_2_jre implementation project(path: ":sdks:java:core", configuration: "shadow") implementation project(path: ":runners:core-java") - implementation library.java.google_http_client_jackson2 + implementation library.java.google_http_client_gson implementation library.java.google_auth_library_oauth2_http implementation library.java.google_api_client implementation library.java.bigdataoss_gcsio diff --git a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java index 180f32c3228f..df9049a8fab2 100644 --- a/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java +++ b/sdks/java/extensions/google-cloud-platform-core/src/main/java/org/apache/beam/sdk/extensions/gcp/util/Transport.java @@ -24,7 +24,6 @@ import com.google.api.client.http.HttpTransport; import com.google.api.client.json.JsonFactory; import com.google.api.client.json.gson.GsonFactory; -import com.google.api.client.json.jackson2.JacksonFactory; import com.google.api.services.storage.Storage; import com.google.auth.Credentials; import com.google.auth.http.HttpCredentialsAdapter; diff --git a/sdks/java/io/google-cloud-platform/build.gradle b/sdks/java/io/google-cloud-platform/build.gradle index 23c56f13a94c..3e322d976c1a 100644 --- a/sdks/java/io/google-cloud-platform/build.gradle +++ b/sdks/java/io/google-cloud-platform/build.gradle @@ -84,7 +84,7 @@ dependencies { implementation library.java.google_cloud_spanner implementation library.java.google_code_gson implementation library.java.google_http_client - implementation library.java.google_http_client_jackson2 + implementation library.java.google_http_client_gson // bigdataoss_util declares old google_oauth_client version that does not have // IdTokenVerifier.verifyPayload method. Let's declare the newer one. implementation library.java.google_oauth_client From fc2f6284260d792c1993d8658a7182774dfd753b Mon Sep 17 00:00:00 2001 From: dragonHead1001001 Date: Thu, 15 Aug 2024 21:32:12 +0530 Subject: [PATCH 3/5] Correcting gradle-wrapper.properties --- gradle/wrapper/gradle-wrapper.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 086e52fca019..b9d2b1b60ee8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,8 @@ #Sat Aug 10 17:06:24 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 92b9071544920f3259c4f2b0a16f70dcc5aff18f Mon Sep 17 00:00:00 2001 From: dragonHead1001001 Date: Thu, 15 Aug 2024 21:59:18 +0530 Subject: [PATCH 4/5] Removing date and time from gradle-properties --- gradle/wrapper/gradle-wrapper.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b9d2b1b60ee8..3fa8f862f753 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,3 @@ -#Sat Aug 10 17:06:24 IST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip From 91b4bdc8f9d62cccb10bd0da994aa2f2422e4b5e Mon Sep 17 00:00:00 2001 From: dragonHead1001001 Date: Sat, 17 Aug 2024 02:40:14 +0530 Subject: [PATCH 5/5] Correcting Format in files --- .../beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java | 3 +-- .../org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java index 7d99043cde73..1b67e516bfbe 100644 --- a/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java +++ b/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java @@ -734,8 +734,7 @@ private void initClient() throws IOException { CloudHealthcareScopes.CLOUD_PLATFORM, StorageScopes.CLOUD_PLATFORM_READ_ONLY)); client = - new CloudHealthcare.Builder( - new NetHttpTransport(), new GsonFactory(), requestInitializer) + new CloudHealthcare.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer) .setApplicationName("apache-beam-hl7v2-io") .build(); httpClient = diff --git a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java index 90c2a647cd45..d3b11547d831 100644 --- a/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java +++ b/sdks/java/io/google-cloud-platform/src/test/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIOTestUtil.java @@ -136,8 +136,7 @@ public static void tearDownTempBucket() throws IOException { request.setReadTimeout(60000); // 1 minute read timeout }; Storage storage = - new Storage.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer) - .build(); + new Storage.Builder(new NetHttpTransport(), new GsonFactory(), requestInitializer).build(); List blobs = storage.objects().list(DEFAULT_TEMP_BUCKET).execute().getItems(); if (blobs != null) { for (StorageObject blob : blobs) {