Skip to content

Commit 63ed2ca

Browse files
authored
fix: use Gson instead of Jackson (#1661)
* use GSon instead of Jackson * remove jackson2 * fix callback
1 parent 8dc6c92 commit 63ed2ca

28 files changed

Lines changed: 57 additions & 64 deletions

google-api-client-appengine/src/test/java/com/google/api/client/googleapis/extensions/appengine/auth/oauth2/AppIdentityCredentialTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.google.api.client.http.HttpRequest;
2121
import com.google.api.client.http.HttpTransport;
2222
import com.google.api.client.json.JsonFactory;
23-
import com.google.api.client.json.jackson2.JacksonFactory;
23+
import com.google.api.client.json.gson.GsonFactory;
2424
import com.google.api.client.testing.http.MockHttpTransport;
2525
import java.io.IOException;
2626
import java.util.Arrays;
@@ -72,7 +72,7 @@ public void testAppEngineCredentialWrapper() throws IOException {
7272
final Collection<String> emptyScopes = Collections.emptyList();
7373

7474
HttpTransport transport = new MockHttpTransport();
75-
JsonFactory jsonFactory = new JacksonFactory();
75+
JsonFactory jsonFactory = new GsonFactory();
7676

7777
MockAppIdentityService appIdentity = new MockAppIdentityService();
7878
appIdentity.setAccessTokenText(expectedAccessToken);
@@ -108,7 +108,7 @@ public void testAppEngineCredentialWrapperGetAccessToken() throws IOException {
108108
final String expectedAccessToken = "ExpectedAccessToken";
109109

110110
HttpTransport transport = new MockHttpTransport();
111-
JsonFactory jsonFactory = new JacksonFactory();
111+
JsonFactory jsonFactory = new GsonFactory();
112112

113113
MockAppIdentityService appIdentity = new MockAppIdentityService();
114114
appIdentity.setAccessTokenText(expectedAccessToken);
@@ -124,7 +124,7 @@ public void testAppEngineCredentialWrapperGetAccessToken() throws IOException {
124124
}
125125

126126
public void testAppEngineCredentialWrapperNullTransportThrows() throws IOException {
127-
JsonFactory jsonFactory = new JacksonFactory();
127+
JsonFactory jsonFactory = new GsonFactory();
128128
try {
129129
new AppIdentityCredential.AppEngineCredentialWrapper(null, jsonFactory);
130130
fail();

google-api-client-jackson2/src/main/java/com/google/api/client/googleapis/notifications/json/jackson2/JacksonNotificationCallback.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
import com.google.api.client.googleapis.notifications.TypedNotificationCallback;
1818
import com.google.api.client.googleapis.notifications.json.JsonNotificationCallback;
1919
import com.google.api.client.json.JsonFactory;
20-
import com.google.api.client.json.jackson2.JacksonFactory;
20+
import com.google.api.client.json.gson.GsonFactory;
2121
import com.google.api.client.util.Beta;
2222

2323
/**
2424
* {@link Beta} <br>
2525
* A {@link TypedNotificationCallback} which uses an JSON content encoding with {@link
26-
* JacksonFactory#getDefaultInstance()}.
26+
* GsonFactory#getDefaultInstance()}.
2727
*
2828
* <p>Must NOT be implemented in form of an anonymous class as this will break serialization.
2929
*
3030
* <p>Implementation should be thread-safe. <b>Example usage:</b>
3131
*
3232
* <pre>
3333
* static class MyNotificationCallback
34-
* extends GsonNotificationCallback{@literal <}ListResponse{@literal >} {
34+
* extends JacksonNotificationCallback{@literal <}ListResponse{@literal >} {
3535
*
3636
* private static final long serialVersionUID = 1L;
3737
*
@@ -67,6 +67,6 @@ public abstract class JacksonNotificationCallback<T> extends JsonNotificationCal
6767

6868
@Override
6969
protected JsonFactory getJsonFactory() {
70-
return JacksonFactory.getDefaultInstance();
70+
return GsonFactory.getDefaultInstance();
7171
}
7272
}

google-api-client/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,9 @@
121121
<groupId>com.google.oauth-client</groupId>
122122
<artifactId>google-oauth-client</artifactId>
123123
</dependency>
124-
<dependency>
125-
<groupId>com.google.http-client</groupId>
126-
<artifactId>google-http-client-jackson2</artifactId>
127-
</dependency>
128124
<dependency>
129125
<groupId>com.google.http-client</groupId>
130126
<artifactId>google-http-client-gson</artifactId>
131-
<scope>test</scope>
132127
</dependency>
133128
<dependency>
134129
<groupId>com.google.http-client</groupId>

google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleAuthorizationCodeTokenRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* static void requestAccessToken() throws IOException {
4444
* try {
4545
* GoogleTokenResponse response =
46-
* new GoogleAuthorizationCodeTokenRequest(new NetHttpTransport(), new JacksonFactory(),
46+
* new GoogleAuthorizationCodeTokenRequest(new NetHttpTransport(), new GsonFactory(),
4747
* "812741506391.apps.googleusercontent.com", "{client_secret}",
4848
* "4/P7q7W91a-oMsCeLvIaQm6bTrgtp7", "https://oauth2-login-demo.appspot.com/code")
4949
* .execute();

google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleRefreshTokenRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* static void refreshAccessToken() throws IOException {
4242
* try {
4343
* TokenResponse response =
44-
* new GoogleRefreshTokenRequest(new NetHttpTransport(), new JacksonFactory(),
44+
* new GoogleRefreshTokenRequest(new NetHttpTransport(), new GsonFactory(),
4545
* "tGzv3JOkF0XG5Qx2TlKWIA", "s6BhdRkqt3", "7Fjfp0ZBr1KtDRbnfVdmIw").execute();
4646
* System.out.println("Access token: " + response.getAccessToken());
4747
* } catch (TokenResponseException e) {

google-api-client/src/main/java/com/google/api/client/googleapis/json/package-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
* headers.setApplicationName("Google-YouTubeSample/1.0");
114114
* headers.gdataVersion = "2";
115115
* JsonCParser parser = new JsonCParser();
116-
* parser.jsonFactory = new JacksonFactory();
116+
* parser.jsonFactory = new GsonFactory();
117117
* transport.addParser(parser);
118118
* // insert authentication code...
119119
* return transport;

google-api-client/src/main/java/com/google/api/client/googleapis/notifications/TypedNotificationCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
*
5252
* {@literal @}Override
5353
* protected ObjectParser getObjectParser(Notification notification) throws IOException {
54-
* return new JsonObjectParser(new JacksonFactory());
54+
* return new JsonObjectParser(new GsonFactory());
5555
* }
5656
*
5757
* {@literal @}Override

google-api-client/src/main/java/com/google/api/client/googleapis/notifications/json/JsonNotificationCallback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
*
5151
* {@literal @}Override
5252
* protected JsonFactory getJsonFactory() throws IOException {
53-
* return new JacksonFactory();
53+
* return new GsonFactory();
5454
* }
5555
*
5656
* {@literal @}Override

google-api-client/src/main/java/com/google/api/client/googleapis/testing/auth/oauth2/MockGoogleCredential.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.google.api.client.http.HttpTransport;
77
import com.google.api.client.json.Json;
88
import com.google.api.client.json.JsonFactory;
9-
import com.google.api.client.json.jackson2.JacksonFactory;
9+
import com.google.api.client.json.gson.GsonFactory;
1010
import com.google.api.client.testing.http.MockHttpTransport;
1111
import com.google.api.client.testing.http.MockLowLevelHttpRequest;
1212
import com.google.api.client.testing.http.MockLowLevelHttpResponse;
@@ -84,7 +84,7 @@ public MockGoogleCredential build() {
8484
setClientAuthentication(new MockClientAuthentication());
8585
}
8686
if (getJsonFactory() == null) {
87-
setJsonFactory(new JacksonFactory());
87+
setJsonFactory(new GsonFactory());
8888
}
8989
return new MockGoogleCredential(this);
9090
}

google-api-client/src/main/java/com/google/api/client/googleapis/testing/auth/oauth2/MockTokenServerTransport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.google.api.client.json.GenericJson;
2222
import com.google.api.client.json.Json;
2323
import com.google.api.client.json.JsonFactory;
24-
import com.google.api.client.json.jackson2.JacksonFactory;
24+
import com.google.api.client.json.gson.GsonFactory;
2525
import com.google.api.client.json.webtoken.JsonWebSignature;
2626
import com.google.api.client.testing.http.MockHttpTransport;
2727
import com.google.api.client.testing.http.MockLowLevelHttpRequest;
@@ -47,7 +47,7 @@ public class MockTokenServerTransport extends MockHttpTransport {
4747
private static final Logger LOGGER = Logger.getLogger(MockTokenServerTransport.class.getName());
4848

4949
static final String EXPECTED_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:jwt-bearer";
50-
static final JsonFactory JSON_FACTORY = new JacksonFactory();
50+
static final JsonFactory JSON_FACTORY = new GsonFactory();
5151
final String tokenServerUrl;
5252
Map<String, String> serviceAccounts = new HashMap<String, String>();
5353
Map<String, String> clients = new HashMap<String, String>();

0 commit comments

Comments
 (0)