diff --git a/pulsar-common/src/main/java/org/apache/pulsar/client/impl/schema/SchemaUtils.java b/pulsar-common/src/main/java/org/apache/pulsar/client/impl/schema/SchemaUtils.java index 9843e638a7d62..9747fb8cae662 100644 --- a/pulsar-common/src/main/java/org/apache/pulsar/client/impl/schema/SchemaUtils.java +++ b/pulsar-common/src/main/java/org/apache/pulsar/client/impl/schema/SchemaUtils.java @@ -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 { diff --git a/pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java b/pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java index d672b4bc2d2eb..651523e72dd23 100644 --- a/pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java +++ b/pulsar-functions/localrun/src/main/java/org/apache/pulsar/functions/LocalRunner.java @@ -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"); diff --git a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyAuthenticationTest.java b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyAuthenticationTest.java index 550aad43c0224..2e74995ee1aa6 100644 --- a/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyAuthenticationTest.java +++ b/pulsar-proxy/src/test/java/org/apache/pulsar/proxy/server/ProxyAuthenticationTest.java @@ -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) {