Skip to content

Commit

Permalink
Remove unnecessary creation of JsonParser object per deprecation doc (a…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljmarshall authored Sep 11, 2021
1 parent a5f0100 commit 04ee81f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContex
}

public static JsonObject toJsonObject(String json) {
JsonParser parser = new JsonParser();
return parser.parse(json).getAsJsonObject();
return JsonParser.parseString(json).getAsJsonObject();
}

private static class SchemaInfoToStringAdapter implements JsonSerializer<SchemaInfo> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public void run() {
for (index = 0; index < futures.length; ++index) {
String json = futures[index].get();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
log.info(gson.toJson(new JsonParser().parse(json)));
log.info(gson.toJson(JsonParser.parseString(json)));
}
} catch (TimeoutException | InterruptedException | ExecutionException e) {
log.error("Could not get status from all local instances");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public String authenticate(AuthenticationDataSource authData) throws Authenticat
commandData = authData.getHttpHeader("BasicAuthentication");
}

JsonParser parser = new JsonParser();
JsonObject element = parser.parse(commandData).getAsJsonObject();
JsonObject element = JsonParser.parseString(commandData).getAsJsonObject();
long expiryTimeInMillis = Long.parseLong(element.get("expiryTime").getAsString());
long currentTimeInMillis = System.currentTimeMillis();
if (expiryTimeInMillis < currentTimeInMillis) {
Expand Down

0 comments on commit 04ee81f

Please sign in to comment.