diff --git a/NOTICE.md b/NOTICE.md index a677353a1c..19af0e4fd3 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -70,7 +70,7 @@ Javassist Version 3.30.2-GA * Project: http://www.javassist.org/ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. -Jackson JAX-RS Providers Version 2.17.2 +Jackson JAX-RS Providers Version 2.18.0 * License: Apache License, 2.0 * Project: https://github.com/FasterXML/jackson-jaxrs-providers * Copyright: (c) 2009-2024 FasterXML, LLC. All rights reserved unless otherwise indicated. diff --git a/examples/NOTICE.md b/examples/NOTICE.md index 9901b179f3..c16b4c6cfc 100644 --- a/examples/NOTICE.md +++ b/examples/NOTICE.md @@ -66,7 +66,7 @@ Javassist Version 3.30.2-GA * Project: http://www.javassist.org/ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. -Jackson JAX-RS Providers Version 2.17.2 +Jackson JAX-RS Providers Version 2.18.0 * License: Apache License, 2.0 * Project: https://github.com/FasterXML/jackson-jaxrs-providers * Copyright: (c) 2009-2023 FasterXML, LLC. All rights reserved unless otherwise indicated. diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java index 955c9b7200..bea071483a 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/DefaultJacksonJaxbJsonProvider.java @@ -18,6 +18,8 @@ import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.StreamReadConstraints; +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.core.json.PackageVersion; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.ObjectReader; @@ -128,17 +130,22 @@ private void updateFactoryConstraints(JsonFactory jsonFactory) { if (maxStringLength != StreamReadConstraints.DEFAULT_MAX_STRING_LEN) { final StreamReadConstraints constraints = jsonFactory.streamReadConstraints(); - jsonFactory.setStreamReadConstraints( - StreamReadConstraints.builder() - // our - .maxStringLength(maxStringLength) - // customers - .maxDocumentLength(constraints.getMaxDocumentLength()) - .maxNameLength(constraints.getMaxNameLength()) - .maxNestingDepth(constraints.getMaxNestingDepth()) - .maxNumberLength(constraints.getMaxNumberLength()) - .build() - ); + StreamReadConstraints.Builder builder = StreamReadConstraints.builder() + // our + .maxStringLength(maxStringLength) + // customers + .maxDocumentLength(constraints.getMaxDocumentLength()) + .maxNameLength(constraints.getMaxNameLength()) + .maxNestingDepth(constraints.getMaxNestingDepth()) + .maxNumberLength(constraints.getMaxNumberLength()); + + if (PackageVersion.VERSION.getMinorVersion() >= 18) { + builder.maxTokenCount(constraints.getMaxTokenCount()); + } else { + LOGGER.warning(LocalizationMessages.ERROR_JACKSON_STREAMREADCONSTRAINTS_218("maxTokenCount")); + } + + jsonFactory.setStreamReadConstraints(builder.build()); } } } \ No newline at end of file diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java index ac6a9a5b6a..396b58951d 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/ProviderBase.java @@ -43,6 +43,7 @@ import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectWriter; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.util.LookupCache; import com.fasterxml.jackson.databind.util.LRUMap; import com.fasterxml.jackson.databind.type.TypeFactory; @@ -186,14 +187,12 @@ public abstract class ProviderBase< /** * Cache for resolved endpoint configurations when reading JSON data */ - protected final LRUMap _readers - = new LRUMap(16, 120); + protected final LookupCache _readers; /** * Cache for resolved endpoint configurations when writing JSON data */ - protected final LRUMap _writers - = new LRUMap(16, 120); + protected final LookupCache _writers; /* /********************************************************** @@ -202,8 +201,9 @@ public abstract class ProviderBase< */ protected ProviderBase(MAPPER_CONFIG mconfig) { - _mapperConfig = mconfig; - _jaxRSFeatures = JAXRS_FEATURE_DEFAULTS; + this(mconfig, + new LRUMap<>(16, 120), + new LRUMap<>(16, 120)); } /** @@ -214,8 +214,19 @@ protected ProviderBase(MAPPER_CONFIG mconfig) { */ @Deprecated // just to denote it should NOT be directly called; will NOT be removed protected ProviderBase() { - _mapperConfig = null; + this(null); + } + /** + * @since 2.17 + */ + protected ProviderBase(MAPPER_CONFIG mconfig, + LookupCache readerCache, + LookupCache writerCache) + { + _mapperConfig = mconfig; _jaxRSFeatures = JAXRS_FEATURE_DEFAULTS; + _readers = readerCache; + _writers = writerCache; } /* diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java index 663eae82b7..f170281ca1 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJaxbJsonProvider.java @@ -25,7 +25,7 @@ */ @Provider @Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" JSON variants -@Produces(MediaType.WILDCARD) +@Produces({MediaType.APPLICATION_JSON, "text/json", MediaType.WILDCARD}) public class JacksonJaxbJsonProvider extends JacksonJsonProvider { /** * Default annotation sets to use, if not explicitly defined during diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java index dc5fff8510..8d602dbc82 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JacksonJsonProvider.java @@ -52,7 +52,7 @@ */ @Provider @Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" JSON variants -@Produces(MediaType.WILDCARD) +@Produces({MediaType.APPLICATION_JSON, "text/json", MediaType.WILDCARD}) public class JacksonJsonProvider extends ProviderBase2.10.0 4.5.14 5.3.1 - 2.17.2 + 2.18.0 1.9.13 3.30.2-GA 1.19.3