fix: move static JSON parsers to local variables (#26889)

This commit is contained in:
Sumit Kumar 2023-09-07 12:00:25 +05:30 committed by GitHub
parent f01a37982f
commit d9321d1134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,6 @@ import reactor.core.Exceptions;
public class ArrayType implements AppsmithType {
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
@Override
public boolean test(String s) {
@ -23,6 +22,8 @@ public class ArrayType implements AppsmithType {
@Override
public String performSmartSubstitution(String s) {
JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
try {
JSONArray jsonArray = (JSONArray) parser.parse(s);
return objectMapper.writeValueAsString(jsonArray);

View File

@ -22,7 +22,6 @@ public class JsonObjectType implements AppsmithType {
private static final TypeAdapter<JsonObject> strictGsonObjectAdapter = new Gson().getAdapter(JsonObject.class);
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
@Override
public boolean test(String s) {
@ -39,6 +38,7 @@ public class JsonObjectType implements AppsmithType {
@Override
public String performSmartSubstitution(String s) {
JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
try {
JSONObject jsonObject = (JSONObject) parser.parse(s);
String jsonString = objectMapper.writeValueAsString(jsonObject);

View File

@ -55,8 +55,6 @@ public class DataTypeStringUtils {
private static ObjectMapper objectMapper = new ObjectMapper();
private static JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
private static final TypeAdapter<JsonObject> strictGsonObjectAdapter = new Gson().getAdapter(JsonObject.class);
@Deprecated(
@ -222,6 +220,7 @@ public class DataTypeStringUtils {
Map.Entry<String, String> parameter = new SimpleEntry<>(replacement, dataType.toString());
insertedParams.add(parameter);
JSONParser parser = new JSONParser(JSONParser.MODE_PERMISSIVE);
String updatedReplacement;
switch (dataType) {
case INTEGER: