Skip to content

Commit ff5f5a8

Browse files
jansupolsenivam
authored andcommitted
Adopt Jackson 2.18.0
Signed-off-by: jansupol <[email protected]>
1 parent 2edf756 commit ff5f5a8

File tree

12 files changed

+71
-29
lines changed

12 files changed

+71
-29
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.17.2
73+
Jackson JAX-RS Providers Version 2.18.0
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.17.2
69+
Jackson JAX-RS Providers Version 2.18.0
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/DefaultJacksonJaxbJsonProvider.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import com.fasterxml.jackson.core.JsonFactory;
2020
import com.fasterxml.jackson.core.StreamReadConstraints;
21+
import com.fasterxml.jackson.core.Version;
22+
import com.fasterxml.jackson.core.json.PackageVersion;
2123
import com.fasterxml.jackson.databind.ObjectMapper;
2224
import com.fasterxml.jackson.databind.Module;
2325
import com.fasterxml.jackson.databind.ObjectReader;
@@ -128,17 +130,22 @@ private void updateFactoryConstraints(JsonFactory jsonFactory) {
128130

129131
if (maxStringLength != StreamReadConstraints.DEFAULT_MAX_STRING_LEN) {
130132
final StreamReadConstraints constraints = jsonFactory.streamReadConstraints();
131-
jsonFactory.setStreamReadConstraints(
132-
StreamReadConstraints.builder()
133-
// our
134-
.maxStringLength(maxStringLength)
135-
// customers
136-
.maxDocumentLength(constraints.getMaxDocumentLength())
137-
.maxNameLength(constraints.getMaxNameLength())
138-
.maxNestingDepth(constraints.getMaxNestingDepth())
139-
.maxNumberLength(constraints.getMaxNumberLength())
140-
.build()
141-
);
133+
StreamReadConstraints.Builder builder = StreamReadConstraints.builder()
134+
// our
135+
.maxStringLength(maxStringLength)
136+
// customers
137+
.maxDocumentLength(constraints.getMaxDocumentLength())
138+
.maxNameLength(constraints.getMaxNameLength())
139+
.maxNestingDepth(constraints.getMaxNestingDepth())
140+
.maxNumberLength(constraints.getMaxNumberLength());
141+
142+
if (PackageVersion.VERSION.getMinorVersion() >= 18) {
143+
builder.maxTokenCount(constraints.getMaxTokenCount());
144+
} else {
145+
LOGGER.warning(LocalizationMessages.ERROR_JACKSON_STREAMREADCONSTRAINTS_218("maxTokenCount"));
146+
}
147+
148+
jsonFactory.setStreamReadConstraints(builder.build());
142149
}
143150
}
144151
}

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import com.fasterxml.jackson.databind.ObjectReader;
4444
import com.fasterxml.jackson.databind.ObjectWriter;
4545
import com.fasterxml.jackson.databind.SerializationFeature;
46+
import com.fasterxml.jackson.databind.util.LookupCache;
4647
import com.fasterxml.jackson.databind.util.LRUMap;
4748
import com.fasterxml.jackson.databind.type.TypeFactory;
4849

@@ -186,14 +187,12 @@ public abstract class ProviderBase<
186187
/**
187188
* Cache for resolved endpoint configurations when reading JSON data
188189
*/
189-
protected final LRUMap<AnnotationBundleKey, EP_CONFIG> _readers
190-
= new LRUMap<AnnotationBundleKey, EP_CONFIG>(16, 120);
190+
protected final LookupCache<AnnotationBundleKey, EP_CONFIG> _readers;
191191

192192
/**
193193
* Cache for resolved endpoint configurations when writing JSON data
194194
*/
195-
protected final LRUMap<AnnotationBundleKey, EP_CONFIG> _writers
196-
= new LRUMap<AnnotationBundleKey, EP_CONFIG>(16, 120);
195+
protected final LookupCache<AnnotationBundleKey, EP_CONFIG> _writers;
197196

198197
/*
199198
/**********************************************************
@@ -202,8 +201,9 @@ public abstract class ProviderBase<
202201
*/
203202

204203
protected ProviderBase(MAPPER_CONFIG mconfig) {
205-
_mapperConfig = mconfig;
206-
_jaxRSFeatures = JAXRS_FEATURE_DEFAULTS;
204+
this(mconfig,
205+
new LRUMap<>(16, 120),
206+
new LRUMap<>(16, 120));
207207
}
208208

209209
/**
@@ -214,8 +214,19 @@ protected ProviderBase(MAPPER_CONFIG mconfig) {
214214
*/
215215
@Deprecated // just to denote it should NOT be directly called; will NOT be removed
216216
protected ProviderBase() {
217-
_mapperConfig = null;
217+
this(null);
218+
}
219+
/**
220+
* @since 2.17
221+
*/
222+
protected ProviderBase(MAPPER_CONFIG mconfig,
223+
LookupCache<AnnotationBundleKey, EP_CONFIG> readerCache,
224+
LookupCache<AnnotationBundleKey, EP_CONFIG> writerCache)
225+
{
226+
_mapperConfig = mconfig;
218227
_jaxRSFeatures = JAXRS_FEATURE_DEFAULTS;
228+
_readers = readerCache;
229+
_writers = writerCache;
219230
}
220231

221232
/*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
@Provider
2727
@Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" JSON variants
28-
@Produces(MediaType.WILDCARD)
28+
@Produces({MediaType.APPLICATION_JSON, "text/json", MediaType.WILDCARD})
2929
public class JacksonJaxbJsonProvider extends JacksonJsonProvider {
3030
/**
3131
* Default annotation sets to use, if not explicitly defined during

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
*/
5353
@Provider
5454
@Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" JSON variants
55-
@Produces(MediaType.WILDCARD)
55+
@Produces({MediaType.APPLICATION_JSON, "text/json", MediaType.WILDCARD})
5656
public class JacksonJsonProvider
5757
extends ProviderBase<JacksonJsonProvider,
5858
ObjectMapper,

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.17.2", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");
14+
"2.18.0", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider");
1515

1616
@Override
1717
public Version version() {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/**
22
* Miscellaneous helper classes used by providers.
33
*/
4-
package com.fasterxml.jackson.jaxrs.util;
4+
package org.glassfish.jersey.jackson.internal.jackson.jaxrs.util;

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.17.2
34+
Jackson JAX-RS Providers version 2.18.0
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.

media/json-jackson/src/main/resources/org/glassfish/jersey/jackson/localization.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
#
1414
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
#
16-
1716
error.jackson.streamreadconstraints=Error setting StreamReadConstraints: {0}. Possibly not Jackson 2.15?
17+
error.jackson.streamreadconstraints218=Error setting StreamReadConstraints: {0}. Possibly not Jackson 2.18?
1818
error.modules.not.loaded=Jackson modules could not be loaded: {0}

0 commit comments

Comments
 (0)