@@ -132,24 +132,16 @@ class BaseDefaultCodecs implements CodecConfigurer.DefaultCodecs, CodecConfigure
132132
133133 private @ Nullable Decoder <?> jacksonJsonDecoder ;
134134
135- private @ Nullable Decoder <?> jackson2JsonDecoder ;
136-
137135 private @ Nullable Encoder <?> jacksonJsonEncoder ;
138136
139- private @ Nullable Encoder <?> jackson2JsonEncoder ;
140-
141137 private @ Nullable Decoder <?> gsonDecoder ;
142138
143139 private @ Nullable Encoder <?> gsonEncoder ;
144140
145141 private @ Nullable Encoder <?> jacksonSmileEncoder ;
146142
147- private @ Nullable Encoder <?> jackson2SmileEncoder ;
148-
149143 private @ Nullable Decoder <?> jacksonSmileDecoder ;
150144
151- private @ Nullable Decoder <?> jackson2SmileDecoder ;
152-
153145 private @ Nullable Decoder <?> protobufDecoder ;
154146
155147 private @ Nullable Encoder <?> protobufEncoder ;
@@ -224,15 +216,11 @@ protected void initWriters() {
224216 */
225217 protected BaseDefaultCodecs (BaseDefaultCodecs other ) {
226218 this .jacksonJsonDecoder = other .jacksonJsonDecoder ;
227- this .jackson2JsonDecoder = other .jackson2JsonDecoder ;
228219 this .jacksonJsonEncoder = other .jacksonJsonEncoder ;
229- this .jackson2JsonEncoder = other .jackson2JsonEncoder ;
230220 this .gsonDecoder = other .gsonDecoder ;
231221 this .gsonEncoder = other .gsonEncoder ;
232222 this .jacksonSmileDecoder = other .jacksonSmileDecoder ;
233- this .jackson2SmileDecoder = other .jackson2SmileDecoder ;
234223 this .jacksonSmileEncoder = other .jacksonSmileEncoder ;
235- this .jackson2SmileEncoder = other .jackson2SmileEncoder ;
236224 this .protobufDecoder = other .protobufDecoder ;
237225 this .protobufEncoder = other .protobufEncoder ;
238226 this .jaxb2Decoder = other .jaxb2Decoder ;
@@ -262,26 +250,13 @@ public void jacksonJsonDecoder(Decoder<?> decoder) {
262250 initObjectReaders ();
263251 }
264252
265- @ Override
266- public void jackson2JsonDecoder (Decoder <?> decoder ) {
267- this .jackson2JsonDecoder = decoder ;
268- initObjectReaders ();
269- }
270-
271253 @ Override
272254 public void jacksonJsonEncoder (Encoder <?> encoder ) {
273255 this .jacksonJsonEncoder = encoder ;
274256 initObjectWriters ();
275257 initTypedWriters ();
276258 }
277259
278- @ Override
279- public void jackson2JsonEncoder (Encoder <?> encoder ) {
280- this .jackson2JsonEncoder = encoder ;
281- initObjectWriters ();
282- initTypedWriters ();
283- }
284-
285260 @ Override
286261 public void gsonDecoder (Decoder <?> decoder ) {
287262 this .gsonDecoder = decoder ;
@@ -301,26 +276,13 @@ public void jacksonSmileDecoder(Decoder<?> decoder) {
301276 initObjectReaders ();
302277 }
303278
304- @ Override
305- public void jackson2SmileDecoder (Decoder <?> decoder ) {
306- this .jackson2SmileDecoder = decoder ;
307- initObjectReaders ();
308- }
309-
310279 @ Override
311280 public void jacksonSmileEncoder (Encoder <?> encoder ) {
312281 this .jacksonSmileEncoder = encoder ;
313282 initObjectWriters ();
314283 initTypedWriters ();
315284 }
316285
317- @ Override
318- public void jackson2SmileEncoder (Encoder <?> encoder ) {
319- this .jackson2SmileEncoder = encoder ;
320- initObjectWriters ();
321- initTypedWriters ();
322- }
323-
324286 @ Override
325287 public void protobufDecoder (Decoder <?> decoder ) {
326288 this .protobufDecoder = decoder ;
@@ -637,7 +599,6 @@ final List<HttpMessageReader<?>> getObjectReaders() {
637599 * Reset and initialize object readers.
638600 * @since 5.3.3
639601 */
640- @ SuppressWarnings ("removal" )
641602 protected void initObjectReaders () {
642603 this .objectReaders .clear ();
643604 if (!this .registerDefaults ) {
@@ -654,25 +615,17 @@ protected void initObjectReaders() {
654615 (KotlinSerializationProtobufDecoder ) this .kotlinSerializationProtobufDecoder :
655616 new KotlinSerializationProtobufDecoder ()));
656617 }
657- if (JACKSON_PRESENT ) {
618+ if (JACKSON_PRESENT || JACKSON_2_PRESENT ) {
658619 addCodec (this .objectReaders , new DecoderHttpMessageReader <>(getJacksonJsonDecoder ()));
659620 }
660- else if (JACKSON_2_PRESENT ) {
661- addCodec (this .objectReaders , new DecoderHttpMessageReader <>(getJackson2JsonDecoder ()));
662- }
663621 else if (GSON_PRESENT ) {
664622 addCodec (this .objectReaders , new DecoderHttpMessageReader <>(getGsonDecoder ()));
665623 }
666624 else if (KOTLIN_SERIALIZATION_JSON_PRESENT ) {
667625 addCodec (this .objectReaders , new DecoderHttpMessageReader <>(getKotlinSerializationJsonDecoder ()));
668626 }
669- if (JACKSON_SMILE_PRESENT ) {
670- addCodec (this .objectReaders , new DecoderHttpMessageReader <>(this .jacksonSmileDecoder != null ?
671- (JacksonSmileDecoder ) this .jacksonSmileDecoder : new JacksonSmileDecoder ()));
672- }
673- else if (JACKSON_2_SMILE_PRESENT ) {
674- addCodec (this .objectReaders , new DecoderHttpMessageReader <>(this .jackson2SmileDecoder != null ?
675- (Jackson2SmileDecoder ) this .jackson2SmileDecoder : new Jackson2SmileDecoder ()));
627+ if (JACKSON_SMILE_PRESENT || JACKSON_2_SMILE_PRESENT ) {
628+ addCodec (this .objectReaders , new DecoderHttpMessageReader <>(getJacksonSmileDecoder ()));
676629 }
677630 if (JAXB_2_PRESENT ) {
678631 addCodec (this .objectReaders , new DecoderHttpMessageReader <>(this .jaxb2Decoder != null ?
@@ -789,7 +742,6 @@ protected void initObjectWriters() {
789742 /**
790743 * Return "base" object writers only, i.e. common to client and server.
791744 */
792- @ SuppressWarnings ("removal" )
793745 final List <HttpMessageWriter <?>> getBaseObjectWriters () {
794746 List <HttpMessageWriter <?>> writers = new ArrayList <>();
795747 if (KOTLIN_SERIALIZATION_CBOR_PRESENT ) {
@@ -802,25 +754,17 @@ final List<HttpMessageWriter<?>> getBaseObjectWriters() {
802754 (KotlinSerializationProtobufEncoder ) this .kotlinSerializationProtobufEncoder :
803755 new KotlinSerializationProtobufEncoder ()));
804756 }
805- if (JACKSON_PRESENT ) {
757+ if (JACKSON_PRESENT || JACKSON_2_PRESENT ) {
806758 addCodec (writers , new EncoderHttpMessageWriter <>(getJacksonJsonEncoder ()));
807759 }
808- else if (JACKSON_2_PRESENT ) {
809- addCodec (writers , new EncoderHttpMessageWriter <>(getJackson2JsonEncoder ()));
810- }
811760 else if (GSON_PRESENT ) {
812761 addCodec (writers , new EncoderHttpMessageWriter <>(getGsonEncoder ()));
813762 }
814763 else if (KOTLIN_SERIALIZATION_JSON_PRESENT ) {
815764 addCodec (writers , new EncoderHttpMessageWriter <>(getKotlinSerializationJsonEncoder ()));
816765 }
817- if (JACKSON_SMILE_PRESENT ) {
818- addCodec (writers , new EncoderHttpMessageWriter <>(this .jacksonSmileEncoder != null ?
819- (JacksonSmileEncoder ) this .jacksonSmileEncoder : new JacksonSmileEncoder ()));
820- }
821- else if (JACKSON_2_SMILE_PRESENT ) {
822- addCodec (writers , new EncoderHttpMessageWriter <>(this .jackson2SmileEncoder != null ?
823- (Jackson2SmileEncoder ) this .jackson2SmileEncoder : new Jackson2SmileEncoder ()));
766+ if (JACKSON_SMILE_PRESENT || JACKSON_2_SMILE_PRESENT ) {
767+ addCodec (writers , new EncoderHttpMessageWriter <>(getJacksonSmileEncoder ()));
824768 }
825769 if (JAXB_2_PRESENT ) {
826770 addCodec (writers , new EncoderHttpMessageWriter <>(this .jaxb2Encoder != null ?
@@ -865,34 +809,55 @@ private void applyDefaultConfig(Map<?, Boolean> readers) {
865809
866810 // Accessors for use in subclasses...
867811
812+ @ SuppressWarnings ("removal" )
868813 protected Decoder <?> getJacksonJsonDecoder () {
869814 if (this .jacksonJsonDecoder == null ) {
870- this .jacksonJsonDecoder = new JacksonJsonDecoder ();
815+ if (JACKSON_PRESENT ) {
816+ this .jacksonJsonDecoder = new JacksonJsonDecoder ();
817+ }
818+ else if (JACKSON_2_PRESENT ) {
819+ this .jacksonJsonDecoder = new Jackson2JsonDecoder ();
820+ }
821+ else {
822+ throw new IllegalStateException ("Jackson not present" );
823+ }
871824 }
872825 return this .jacksonJsonDecoder ;
873826 }
874827
875- @ SuppressWarnings ("removal" )
828+ /**
829+ * Get or initialize a Jackson JSON decoder.
830+ * @deprecated in favor of {@link #getJacksonJsonEncoder()}
831+ */
832+ @ Deprecated (since = "7.0" , forRemoval = true )
876833 protected Decoder <?> getJackson2JsonDecoder () {
877- if (this .jackson2JsonDecoder == null ) {
878- this .jackson2JsonDecoder = new Jackson2JsonDecoder ();
879- }
880- return this .jackson2JsonDecoder ;
834+ return getJacksonJsonDecoder ();
881835 }
882836
837+ @ SuppressWarnings ("removal" )
883838 protected Encoder <?> getJacksonJsonEncoder () {
884839 if (this .jacksonJsonEncoder == null ) {
840+ if (JACKSON_PRESENT ) {
841+ this .jacksonJsonEncoder = new JacksonJsonEncoder ();
842+ }
843+ else if (JACKSON_2_PRESENT ) {
844+ this .jacksonJsonEncoder = new Jackson2JsonEncoder ();
845+ }
846+ else {
847+ throw new IllegalStateException ("Jackson not present" );
848+ }
885849 this .jacksonJsonEncoder = new JacksonJsonEncoder ();
886850 }
887851 return this .jacksonJsonEncoder ;
888852 }
889853
890- @ SuppressWarnings ("removal" )
854+ /**
855+ * Get or initialize a Jackson JSON encoder.
856+ * @deprecated in favor of {@link #getJacksonJsonEncoder()}
857+ */
858+ @ Deprecated (since = "7.0" , forRemoval = true )
891859 protected Encoder <?> getJackson2JsonEncoder () {
892- if (this .jackson2JsonEncoder == null ) {
893- this .jackson2JsonEncoder = new Jackson2JsonEncoder ();
894- }
895- return this .jackson2JsonEncoder ;
860+ return getJacksonJsonEncoder ();
896861 }
897862
898863 protected Decoder <?> getGsonDecoder () {
@@ -909,6 +874,38 @@ protected Encoder<?> getGsonEncoder() {
909874 return this .gsonEncoder ;
910875 }
911876
877+ @ SuppressWarnings ("removal" )
878+ protected Decoder <?> getJacksonSmileDecoder () {
879+ if (this .jacksonSmileDecoder == null ) {
880+ if (JACKSON_PRESENT ) {
881+ this .jacksonSmileDecoder = new JacksonSmileDecoder ();
882+ }
883+ else if (JACKSON_2_PRESENT ) {
884+ this .jacksonSmileDecoder = new Jackson2SmileDecoder ();
885+ }
886+ else {
887+ throw new IllegalStateException ("Jackson not present" );
888+ }
889+ }
890+ return this .jacksonSmileDecoder ;
891+ }
892+
893+ @ SuppressWarnings ("removal" )
894+ protected Encoder <?> getJacksonSmileEncoder () {
895+ if (this .jacksonSmileEncoder == null ) {
896+ if (JACKSON_PRESENT ) {
897+ this .jacksonSmileEncoder = new JacksonSmileEncoder ();
898+ }
899+ else if (JACKSON_2_PRESENT ) {
900+ this .jacksonSmileEncoder = new Jackson2SmileEncoder ();
901+ }
902+ else {
903+ throw new IllegalStateException ("Jackson not present" );
904+ }
905+ }
906+ return this .jacksonSmileEncoder ;
907+ }
908+
912909 protected Decoder <?> getKotlinSerializationJsonDecoder () {
913910 if (this .kotlinSerializationJsonDecoder == null ) {
914911 this .kotlinSerializationJsonDecoder = new KotlinSerializationJsonDecoder ();
0 commit comments