Skip to content

Commit 1f13aa5

Browse files
committed
Jackson update to 2.19.1
Signed-off-by: Maxim Nesen <[email protected]>
1 parent c06969c commit 1f13aa5

File tree

8 files changed

+49
-27
lines changed

8 files changed

+49
-27
lines changed

NOTICE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Javassist Version 3.30.2-GA
7070
* Project: http://www.javassist.org/
7171
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
7272

73-
Jackson JAX-RS Providers Version 2.18.0
73+
Jackson JAX-RS Providers Version 2.19.1
7474
* License: Apache License, 2.0
7575
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7676
* Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated.

examples/NOTICE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Javassist Version 3.30.2-GA
6666
* Project: http://www.javassist.org/
6767
* Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
6868

69-
Jackson JAX-RS Providers Version 2.18.0
69+
Jackson JAX-RS Providers Version 2.19.1
7070
* License: Apache License, 2.0
7171
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
7272
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
import java.io.Reader;
77
import java.io.Writer;
88
import java.lang.annotation.Annotation;
9+
import java.lang.reflect.Constructor;
910
import java.lang.reflect.Type;
11+
import java.security.AccessController;
12+
import java.security.PrivilegedAction;
1013
import java.util.ArrayList;
1114
import java.util.Collection;
1215
import java.util.HashMap;
@@ -18,9 +21,12 @@
1821
import javax.ws.rs.core.NoContentException;
1922
import javax.ws.rs.core.Response;
2023
import javax.ws.rs.core.StreamingOutput;
24+
import javax.ws.rs.ext.ContextResolver;
2125
import javax.ws.rs.ext.MessageBodyReader;
2226
import javax.ws.rs.ext.MessageBodyWriter;
27+
import javax.ws.rs.ext.Providers;
2328

29+
import com.fasterxml.jackson.core.PrettyPrinter;
2430
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.AnnotationBundleKey;
2531
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations;
2632
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.EndpointConfigBase;
@@ -216,12 +222,13 @@ protected ProviderBase(MAPPER_CONFIG mconfig) {
216222
protected ProviderBase() {
217223
this(null);
218224
}
225+
219226
/**
220227
* @since 2.17
221228
*/
222229
protected ProviderBase(MAPPER_CONFIG mconfig,
223-
LookupCache<AnnotationBundleKey, EP_CONFIG> readerCache,
224-
LookupCache<AnnotationBundleKey, EP_CONFIG> writerCache)
230+
LookupCache<AnnotationBundleKey, EP_CONFIG> readerCache,
231+
LookupCache<AnnotationBundleKey, EP_CONFIG> writerCache)
225232
{
226233
_mapperConfig = mconfig;
227234
_jaxRSFeatures = JAXRS_FEATURE_DEFAULTS;
@@ -612,7 +619,12 @@ public void writeTo(Object value, Class<?> type, Type genericType, Annotation[]
612619
try {
613620
// Want indentation?
614621
if (writer.isEnabled(SerializationFeature.INDENT_OUTPUT)) {
615-
g.useDefaultPrettyPrinter();
622+
PrettyPrinter defaultPrettyPrinter = writer.getConfig().getDefaultPrettyPrinter();
623+
if (defaultPrettyPrinter != null) {
624+
g.setPrettyPrinter(defaultPrettyPrinter);
625+
} else {
626+
g.useDefaultPrettyPrinter();
627+
}
616628
}
617629
JavaType rootType = null;
618630

@@ -999,6 +1011,24 @@ protected IOException _createNoContentException() {
9991011
/**********************************************************
10001012
*/
10011013

1014+
// @since 2.19
1015+
protected <OM extends ObjectMapper> OM _locateMapperViaProvider(Class<?> type, MediaType mediaType,
1016+
Class<OM> mapperType, Providers providers) {
1017+
if (providers != null) {
1018+
ContextResolver<OM> resolver = providers.getContextResolver(mapperType, mediaType);
1019+
// Above should work as is, but due to this bug
1020+
// [https://jersey.dev.java.net/issues/show_bug.cgi?id=288]
1021+
// in Jersey, it doesn't. But this works until resolution of the issue:
1022+
if (resolver == null) {
1023+
resolver = providers.getContextResolver(mapperType, null);
1024+
}
1025+
if (resolver != null) {
1026+
return resolver.getContext(type);
1027+
}
1028+
}
1029+
return null;
1030+
}
1031+
10021032
protected static boolean _containedIn(Class<?> mainType, HashSet<ClassKey> set)
10031033
{
10041034
if (set != null) {

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.fasterxml.jackson.databind.ObjectMapper;
2020
import com.fasterxml.jackson.databind.ObjectReader;
2121
import com.fasterxml.jackson.databind.ObjectWriter;
22+
import com.fasterxml.jackson.databind.json.JsonMapper;
2223

2324
/**
2425
* Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
@@ -202,21 +203,12 @@ protected boolean hasMatchingMediaType(MediaType mediaType)
202203
@Override
203204
protected ObjectMapper _locateMapperViaProvider(Class<?> type, MediaType mediaType)
204205
{
205-
if (_providers != null) {
206-
ContextResolver<ObjectMapper> resolver = _providers.getContextResolver(ObjectMapper.class, mediaType);
207-
/* Above should work as is, but due to this bug
208-
* [https://jersey.dev.java.net/issues/show_bug.cgi?id=288]
209-
* in Jersey, it doesn't. But this works until resolution of
210-
* the issue:
211-
*/
212-
if (resolver == null) {
213-
resolver = _providers.getContextResolver(ObjectMapper.class, null);
214-
}
215-
if (resolver != null) {
216-
return resolver.getContext(type);
217-
}
206+
// 26-Nov-2024, tatu: [jakarta-rs#36] Look for JsonMapper primarily
207+
ObjectMapper m =_locateMapperViaProvider(type, mediaType, JsonMapper.class, _providers);
208+
if (m == null) {
209+
m = _locateMapperViaProvider(type, mediaType, ObjectMapper.class, _providers);
218210
}
219-
return null;
211+
return m;
220212
}
221213

222214
@Override

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JsonMapperConfigurator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.fasterxml.jackson.databind.ObjectMapper;
1111
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
1212
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
13+
import com.fasterxml.jackson.databind.json.JsonMapper;
1314

1415
/**
1516
* Helper class used to encapsulate details of configuring an
@@ -49,7 +50,7 @@ public ObjectMapper getDefaultMapper() {
4950
_lock.lock();
5051
try {
5152
if (_defaultMapper == null) {
52-
_defaultMapper = new ObjectMapper();
53+
_defaultMapper = new JsonMapper();
5354
_setAnnotations(_defaultMapper, _defaultAnnotationsToUse);
5455
}
5556
} finally {
@@ -77,7 +78,7 @@ protected ObjectMapper mapper()
7778
_lock.lock();
7879
try {
7980
if (_mapper == null) {
80-
_mapper = new ObjectMapper();
81+
_mapper = new JsonMapper();
8182
_setAnnotations(_mapper, _defaultAnnotationsToUse);
8283
}
8384
} finally {
@@ -120,9 +121,8 @@ protected AnnotationIntrospector _resolveIntrospector(Annotations ann)
120121
case JACKSON:
121122
return new JacksonAnnotationIntrospector();
122123
case JAXB:
123-
/* For this, need to use indirection just so that error occurs
124-
* when we get here, and not when this class is being loaded
125-
*/
124+
// For this, need to use indirection just so that error occurs
125+
// when we get here, and not when this class is being loaded
126126
try {
127127
if (_jaxbIntrospectorClass == null) {
128128
_jaxbIntrospectorClass = JaxbAnnotationIntrospector.class;

media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/PackageVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
public final class PackageVersion implements Versioned {
1313
public final static Version VERSION = VersionUtil.parseVersion(
14-
"2.18.0", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");
14+
"2.19.1", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");
1515

1616
@Override
1717
public Version version() {

media/json-jackson/src/main/resources/META-INF/NOTICE.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ The project maintains the following source code repositories:
3131

3232
## Third-party Content
3333

34-
Jackson JAX-RS Providers version 2.18.0
34+
Jackson JAX-RS Providers version 2.19.1
3535
* License: Apache License, 2.0
3636
* Project: https://github.com/FasterXML/jackson-jaxrs-providers
3737
* Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@
22372237
<xmlunit.version>2.10.0</xmlunit.version>
22382238
<httpclient.version>4.5.14</httpclient.version>
22392239
<httpclient5.version>5.3.1</httpclient5.version>
2240-
<jackson.version>2.18.0</jackson.version>
2240+
<jackson.version>2.19.1</jackson.version>
22412241
<jackson1.version>1.9.13</jackson1.version>
22422242
<javassist.version>3.30.2-GA</javassist.version>
22432243
<jersey1.version>1.19.3</jersey1.version>

0 commit comments

Comments
 (0)