Skip to content

Commit a194fa6

Browse files
committed
Update dependencies and fix Gson compatibility
Upgrade dependency versions (gson 2.13.2, swagger-annotations 1.6.16, commons-lang3 3.17.0, threetenbp 1.7.2, log4j 2.24.3, junit 4.13.2). Replace deprecated ISO8601Utils with SimpleDateFormat and use Strictness.LENIENT in place of setLenient for newer Gson API. Remove unused AndroidManifest.xml.
1 parent 0bb7785 commit a194fa6

3 files changed

Lines changed: 20 additions & 17 deletions

File tree

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,18 @@ artifacts {
118118
}
119119

120120
dependencies {
121-
implementation 'io.swagger:swagger-annotations:1.5.22'
121+
implementation 'io.swagger:swagger-annotations:1.6.16'
122122
implementation "com.google.code.findbugs:jsr305:3.0.2"
123123
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
124124
implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
125-
implementation 'com.google.code.gson:gson:2.8.6'
126-
implementation 'io.gsonfire:gson-fire:1.8.4'
127-
implementation 'org.apache.commons:commons-lang3:3.10'
128-
implementation 'org.threeten:threetenbp:1.4.3'
125+
implementation 'com.google.code.gson:gson:2.13.2'
126+
implementation 'io.gsonfire:gson-fire:1.9.0'
127+
implementation 'org.apache.commons:commons-lang3:3.17.0'
128+
implementation 'org.threeten:threetenbp:1.7.2'
129129
implementation 'javax.annotation:javax.annotation-api:1.3.2'
130130
implementation 'org.slf4j:slf4j-api:2.0.17'
131-
implementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0'
132-
testImplementation 'junit:junit:4.13.1'
131+
implementation 'org.apache.logging.log4j:log4j-slf4j2-impl:2.24.3'
132+
testImplementation 'junit:junit:4.13.2'
133133
}
134134

135135
javadoc {

src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/java/com/adzerk/sdk/generated/JSON.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.google.gson.GsonBuilder;
1818
import com.google.gson.JsonParseException;
1919
import com.google.gson.TypeAdapter;
20-
import com.google.gson.internal.bind.util.ISO8601Utils;
20+
import com.google.gson.Strictness;
2121
import com.google.gson.stream.JsonReader;
2222
import com.google.gson.stream.JsonWriter;
2323
import com.google.gson.JsonElement;
@@ -35,13 +35,20 @@
3535
import java.lang.reflect.Type;
3636
import java.text.DateFormat;
3737
import java.text.ParseException;
38-
import java.text.ParsePosition;
38+
import java.text.SimpleDateFormat;
3939
import java.util.Date;
4040
import java.util.Locale;
4141
import java.util.Map;
4242
import java.util.HashMap;
43+
import java.util.TimeZone;
4344

4445
public class JSON {
46+
private static final DateFormat ISO8601DateFormat;
47+
static {
48+
ISO8601DateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.US);
49+
ISO8601DateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
50+
}
51+
4552
private Gson gson;
4653
private boolean isLenientOnJson = false;
4754
private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
@@ -139,8 +146,7 @@ public <T> T deserialize(String body, Type returnType) {
139146
try {
140147
if (isLenientOnJson) {
141148
JsonReader jsonReader = new JsonReader(new StringReader(body));
142-
// see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean)
143-
jsonReader.setLenient(true);
149+
jsonReader.setStrictness(Strictness.LENIENT);
144150
return gson.fromJson(jsonReader, returnType);
145151
} else {
146152
return gson.fromJson(body, returnType);
@@ -325,7 +331,7 @@ public java.sql.Date read(JsonReader in) throws IOException {
325331
if (dateFormat != null) {
326332
return new java.sql.Date(dateFormat.parse(date).getTime());
327333
}
328-
return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime());
334+
return new java.sql.Date(ISO8601DateFormat.parse(date).getTime());
329335
} catch (ParseException e) {
330336
throw new JsonParseException(e);
331337
}
@@ -360,7 +366,7 @@ public void write(JsonWriter out, Date date) throws IOException {
360366
if (dateFormat != null) {
361367
value = dateFormat.format(date);
362368
} else {
363-
value = ISO8601Utils.format(date, true);
369+
value = ISO8601DateFormat.format(date);
364370
}
365371
out.value(value);
366372
}
@@ -379,7 +385,7 @@ public Date read(JsonReader in) throws IOException {
379385
if (dateFormat != null) {
380386
return dateFormat.parse(date);
381387
}
382-
return ISO8601Utils.parse(date, new ParsePosition(0));
388+
return ISO8601DateFormat.parse(date);
383389
} catch (ParseException e) {
384390
throw new JsonParseException(e);
385391
}

0 commit comments

Comments
 (0)