Replace JacksonFactory with GsonFactory (#2173)

JacksonFactory is deprecated and GsonFactory is the recommended
replacement.
This commit is contained in:
Lai Jiang 2023-10-04 17:02:13 -04:00 committed by GitHub
parent 7a84844000
commit 2da8ea0185
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -34,7 +34,7 @@ import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.LowLevelHttpRequest; import com.google.api.client.http.LowLevelHttpRequest;
import com.google.api.client.http.LowLevelHttpResponse; import com.google.api.client.http.LowLevelHttpResponse;
import com.google.api.client.json.Json; 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.HttpTesting; import com.google.api.client.testing.http.HttpTesting;
import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockHttpTransport;
import com.google.api.client.testing.http.MockLowLevelHttpRequest; import com.google.api.client.testing.http.MockLowLevelHttpRequest;
@ -300,6 +300,6 @@ class DirectoryGroupsConnectionTest {
HttpRequest request = transport.createRequestFactory() HttpRequest request = transport.createRequestFactory()
.buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL) .buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL)
.setThrowExceptionOnExecuteError(false); .setThrowExceptionOnExecuteError(false);
return GoogleJsonResponseException.from(new JacksonFactory(), request.execute()); return GoogleJsonResponseException.from(new GsonFactory(), request.execute());
} }
} }

View file

@ -26,7 +26,7 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
import com.google.api.client.http.GenericUrl; import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.javanet.NetHttpTransport; 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.client.util.store.AbstractDataStoreFactory; import com.google.api.client.util.store.AbstractDataStoreFactory;
import com.google.api.client.util.store.DataStore; import com.google.api.client.util.store.DataStore;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -74,7 +74,7 @@ class AuthModuleTest {
// We need to set the following fields because they are checked when // We need to set the following fields because they are checked when
// Credential#setRefreshToken is called. However they are not actually persisted in the // Credential#setRefreshToken is called. However they are not actually persisted in the
// DataStore and not actually used in tests. // DataStore and not actually used in tests.
.setJsonFactory(new JacksonFactory()) .setJsonFactory(new GsonFactory())
.setTransport(new NetHttpTransport()) .setTransport(new NetHttpTransport())
.setTokenServerUrl(new GenericUrl("https://accounts.google.com/o/oauth2/token")) .setTokenServerUrl(new GenericUrl("https://accounts.google.com/o/oauth2/token"))
.setClientAuthentication(new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET)) .setClientAuthentication(new ClientParametersAuthentication(CLIENT_ID, CLIENT_SECRET))
@ -146,7 +146,7 @@ class AuthModuleTest {
private Credential getCredential() { private Credential getCredential() {
// Reconstruct the entire dependency graph, injecting FakeDataStoreFactory and credential // Reconstruct the entire dependency graph, injecting FakeDataStoreFactory and credential
// parameters. // parameters.
JacksonFactory jsonFactory = new JacksonFactory(); GsonFactory jsonFactory = new GsonFactory();
GoogleClientSecrets clientSecrets = getSecrets(); GoogleClientSecrets clientSecrets = getSecrets();
ImmutableList<String> scopes = ImmutableList.of("scope1"); ImmutableList<String> scopes = ImmutableList.of("scope1");
return AuthModule.provideCredential( return AuthModule.provideCredential(