diff --git a/extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java b/extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java index c284fc4bc3..5d3d865434 100644 --- a/extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java +++ b/extension/src/main/java/com/alibaba/fastjson2/support/retrofit/Retrofit2ConverterFactory.java @@ -24,14 +24,14 @@ public class Retrofit2ConverterFactory extends Converter.Factory { private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8"); - private FastJsonConfig fastJsonConfig; + private FastJsonConfig config; public Retrofit2ConverterFactory() { - this.fastJsonConfig = new FastJsonConfig(); + this.config = new FastJsonConfig(); } public Retrofit2ConverterFactory(FastJsonConfig fastJsonConfig) { - this.fastJsonConfig = fastJsonConfig; + this.config = fastJsonConfig; } public static Retrofit2ConverterFactory create() { @@ -61,11 +61,11 @@ public Converter requestBodyConverter(Type type, // } public FastJsonConfig getFastJsonConfig() { - return fastJsonConfig; + return config; } public Retrofit2ConverterFactory setFastJsonConfig(FastJsonConfig fastJsonConfig) { - this.fastJsonConfig = fastJsonConfig; + this.config = fastJsonConfig; return this; } @@ -80,8 +80,7 @@ final class ResponseBodyConverter @Override public T convert(ResponseBody value) throws IOException { try { - return JSON.parseObject(value.bytes(), type, - fastJsonConfig.getDateFormat(), fastJsonConfig.getReaderFeatures()); + return JSON.parseObject(value.bytes(), type, config.getDateFormat(), config.getReaderFeatures()); } catch (Exception e) { throw new IOException("JSON parse error: " + e.getMessage(), e); } finally { @@ -98,8 +97,7 @@ final class RequestBodyConverter @Override public RequestBody convert(T value) throws IOException { try { - byte[] content = JSON.toJSONBytes(value, fastJsonConfig.getDateFormat(), - fastJsonConfig.getWriterFilters(), fastJsonConfig.getWriterFeatures()); + byte[] content = JSON.toJSONBytes(value, config.getDateFormat(), config.getWriterFilters(), config.getWriterFeatures()); return RequestBody.create(MEDIA_TYPE, content); } catch (Exception e) { throw new IOException("Could not write JSON: " + e.getMessage(), e); diff --git a/extension/src/main/java/com/alibaba/fastjson2/support/spring/http/converter/FastJsonHttpMessageConverter.java b/extension/src/main/java/com/alibaba/fastjson2/support/spring/http/converter/FastJsonHttpMessageConverter.java index 12256a1fba..5aa93bcb5c 100644 --- a/extension/src/main/java/com/alibaba/fastjson2/support/spring/http/converter/FastJsonHttpMessageConverter.java +++ b/extension/src/main/java/com/alibaba/fastjson2/support/spring/http/converter/FastJsonHttpMessageConverter.java @@ -34,7 +34,7 @@ public class FastJsonHttpMessageConverter /** * with fastJson config */ - private FastJsonConfig fastJsonConfig = new FastJsonConfig(); + private FastJsonConfig config = new FastJsonConfig(); /** * Can serialize/deserialize all types. @@ -47,14 +47,14 @@ public FastJsonHttpMessageConverter() { * @return the fastJsonConfig. */ public FastJsonConfig getFastJsonConfig() { - return fastJsonConfig; + return config; } /** * @param fastJsonConfig the fastJsonConfig to set. */ public void setFastJsonConfig(FastJsonConfig fastJsonConfig) { - this.fastJsonConfig = fastJsonConfig; + this.config = fastJsonConfig; } @Override @@ -105,8 +105,7 @@ private Object readType(Type type, HttpInputMessage inputMessage) { } byte[] bytes = baos.toByteArray(); - return JSON.parseObject(bytes, type, - fastJsonConfig.getDateFormat(), fastJsonConfig.getReaderFeatures()); + return JSON.parseObject(bytes, type, config.getDateFormat(), config.getReaderFeatures()); } catch (JSONException ex) { throw new HttpMessageNotReadableException("JSON parse error: " + ex.getMessage(), ex, inputMessage); } catch (IOException ex) { @@ -119,10 +118,9 @@ protected void writeInternal(Object object, HttpOutputMessage outputMessage) thr try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { HttpHeaders headers = outputMessage.getHeaders(); - int len = JSON.writeTo(baos, object, fastJsonConfig.getDateFormat(), - fastJsonConfig.getWriterFilters(), fastJsonConfig.getWriterFeatures()); + int len = JSON.writeTo(baos, object, config.getDateFormat(), config.getWriterFilters(), config.getWriterFeatures()); - if (headers.getContentLength() < 0 && fastJsonConfig.isWriteContentLength()) { + if (headers.getContentLength() < 0 && config.isWriteContentLength()) { headers.setContentLength(len); } diff --git a/extension/src/main/java/com/alibaba/fastjson2/support/spring/webservlet/view/FastJsonJsonView.java b/extension/src/main/java/com/alibaba/fastjson2/support/spring/webservlet/view/FastJsonJsonView.java index 7a40db0ee9..aeaa45fa79 100644 --- a/extension/src/main/java/com/alibaba/fastjson2/support/spring/webservlet/view/FastJsonJsonView.java +++ b/extension/src/main/java/com/alibaba/fastjson2/support/spring/webservlet/view/FastJsonJsonView.java @@ -10,7 +10,6 @@ import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import java.io.ByteArrayOutputStream; import java.util.HashMap; import java.util.Map; @@ -43,7 +42,7 @@ public class FastJsonJsonView /** * with fastJson config */ - private FastJsonConfig fastJsonConfig = new FastJsonConfig(); + private FastJsonConfig config = new FastJsonConfig(); /** * Set default param. @@ -57,14 +56,14 @@ public FastJsonJsonView() { * @return the fastJsonConfig. */ public FastJsonConfig getFastJsonConfig() { - return fastJsonConfig; + return config; } /** * @param fastJsonConfig the fastJsonConfig to set. */ public void setFastJsonConfig(FastJsonConfig fastJsonConfig) { - this.fastJsonConfig = fastJsonConfig; + this.config = fastJsonConfig; } /** @@ -100,9 +99,9 @@ protected void renderMergedOutputModel(Map model, // ByteArrayOutputStream outnew = new ByteArrayOutputStream(); - int len = JSON.writeTo(outnew, value, fastJsonConfig.getDateFormat(), fastJsonConfig.getWriterFilters(), fastJsonConfig.getWriterFeatures()); + int len = JSON.writeTo(outnew, value, config.getDateFormat(), config.getWriterFilters(), config.getWriterFeatures()); - if (fastJsonConfig.isWriteContentLength()) { + if (config.isWriteContentLength()) { // Write content length (determined via byte array). response.setContentLength(len); } @@ -118,7 +117,7 @@ protected void renderMergedOutputModel(Map model, // protected void prepareResponse(HttpServletRequest request, // HttpServletResponse response) { setResponseContentType(request, response); - response.setCharacterEncoding(fastJsonConfig.getCharset().name()); + response.setCharacterEncoding(config.getCharset().name()); if (this.disableCaching) { response.addHeader("Pragma", "no-cache"); response.addHeader("Cache-Control", "no-cache, no-store, max-age=0"); @@ -144,7 +143,7 @@ public void setDisableCaching(boolean disableCaching) { * The default setting is {@code false}. */ public void setUpdateContentLength(boolean updateContentLength) { - this.fastJsonConfig.setWriteContentLength(updateContentLength); + this.config.setWriteContentLength(updateContentLength); } /** diff --git a/extension/src/main/java/com/alibaba/fastjson2/support/spring/websocket/sockjs/FastjsonSockJsMessageCodec.java b/extension/src/main/java/com/alibaba/fastjson2/support/spring/websocket/sockjs/FastjsonSockJsMessageCodec.java index df0b291182..c9c4539e46 100644 --- a/extension/src/main/java/com/alibaba/fastjson2/support/spring/websocket/sockjs/FastjsonSockJsMessageCodec.java +++ b/extension/src/main/java/com/alibaba/fastjson2/support/spring/websocket/sockjs/FastjsonSockJsMessageCodec.java @@ -9,14 +9,14 @@ public class FastjsonSockJsMessageCodec extends AbstractSockJsMessageCodec { - private FastJsonConfig fastJsonConfig = new FastJsonConfig(); + private FastJsonConfig config = new FastJsonConfig(); public FastJsonConfig getFastJsonConfig() { - return fastJsonConfig; + return config; } public void setFastJsonConfig(FastJsonConfig fastJsonConfig) { - this.fastJsonConfig = fastJsonConfig; + this.config = fastJsonConfig; } @Override @@ -36,7 +36,7 @@ protected char[] applyJsonQuoting(String content) { @Override public String encode(String... messages) { - JSONWriter jsonWriter = JSONWriter.of(fastJsonConfig.getWriterFeatures()); + JSONWriter jsonWriter = JSONWriter.of(config.getWriterFeatures()); if (jsonWriter.isUTF8()) { jsonWriter.writeRaw(new byte[]{'a'}); } else {