From 4235e57f89457791e2b89a744cb132711627a6ef Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Tue, 3 Jan 2023 10:05:33 +0100 Subject: [PATCH] Jackson version update to 2.14.1 Signed-off-by: Maxim Nesen --- NOTICE.md | 2 +- .../jackson/jaxrs/base/ProviderBase.java | 134 +++++++++--------- .../jaxrs/cfg/AnnotationBundleKey.java | 59 ++++---- .../jackson/jaxrs/json/PackageVersion.java | 2 +- .../main/resources/META-INF/NOTICE.markdown | 2 +- pom.xml | 4 +- 6 files changed, 103 insertions(+), 100 deletions(-) diff --git a/NOTICE.md b/NOTICE.md index 1de0f76253..dbb6410048 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -70,7 +70,7 @@ Javassist Version 3.25.0-GA * Project: http://www.javassist.org/ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved. -Jackson JAX-RS Providers Version 2.13.3 +Jackson JAX-RS Providers Version 2.14.1 * License: Apache License, 2.0 * Project: https://github.com/FasterXML/jackson-jaxrs-providers * Copyright: (c) 2009-2022 FasterXML, LLC. All rights reserved unless otherwise indicated. 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 0a970f5a63..34b8231291 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 @@ -47,12 +47,12 @@ import com.fasterxml.jackson.databind.type.TypeFactory; public abstract class ProviderBase< - THIS extends ProviderBase, - MAPPER extends ObjectMapper, - EP_CONFIG extends EndpointConfigBase, - MAPPER_CONFIG extends MapperConfiguratorBase -> - implements + THIS extends ProviderBase, + MAPPER extends ObjectMapper, + EP_CONFIG extends EndpointConfigBase, + MAPPER_CONFIG extends MapperConfiguratorBase + > + implements MessageBodyReader, MessageBodyWriter, Versioned @@ -78,10 +78,10 @@ public abstract class ProviderBase< protected final static HashSet DEFAULT_UNTOUCHABLES = new HashSet(); static { // First, I/O things (direct matches) - DEFAULT_UNTOUCHABLES.add(new ClassKey(InputStream.class)); - DEFAULT_UNTOUCHABLES.add(new ClassKey(Reader.class)); - DEFAULT_UNTOUCHABLES.add(new ClassKey(OutputStream.class)); - DEFAULT_UNTOUCHABLES.add(new ClassKey(Writer.class)); + DEFAULT_UNTOUCHABLES.add(new ClassKey(java.io.InputStream.class)); + DEFAULT_UNTOUCHABLES.add(new ClassKey(java.io.Reader.class)); + DEFAULT_UNTOUCHABLES.add(new ClassKey(java.io.OutputStream.class)); + DEFAULT_UNTOUCHABLES.add(new ClassKey(java.io.Writer.class)); // then some primitive types DEFAULT_UNTOUCHABLES.add(new ClassKey(char[].class)); @@ -98,7 +98,7 @@ public abstract class ProviderBase< * (never try to deserialize instances of these types). */ public final static Class[] DEFAULT_UNREADABLES = new Class[] { - InputStream.class, Reader.class + InputStream.class, Reader.class }; /** @@ -106,13 +106,13 @@ public abstract class ProviderBase< * (never try to serialize instances of these types). */ public final static Class[] DEFAULT_UNWRITABLES = new Class[] { - InputStream.class, // as per [Issue#19] - OutputStream.class, Writer.class, - StreamingOutput.class, Response.class + InputStream.class, // as per [Issue#19] + OutputStream.class, Writer.class, + StreamingOutput.class, Response.class }; protected final static int JAXRS_FEATURE_DEFAULTS = JaxRSFeature.collectDefaults(); - + /* /********************************************************** /* General configuration @@ -124,7 +124,7 @@ public abstract class ProviderBase< * of {@link ObjectMapper} */ protected final MAPPER_CONFIG _mapperConfig; - + /** * Map that contains overrides to default list of untouchable * types: true meaning that entry is untouchable, @@ -150,7 +150,7 @@ public abstract class ProviderBase< /** * Feature flags set. - * + * * @since 2.3 */ protected int _jaxRSFeatures; @@ -164,7 +164,7 @@ public abstract class ProviderBase< * View to use for writing if none defined for the end point. */ protected Class _defaultWriteView; - + /* /********************************************************** /* Excluded types @@ -187,13 +187,13 @@ public abstract class ProviderBase< * Cache for resolved endpoint configurations when reading JSON data */ protected final LRUMap _readers - = new LRUMap(16, 120); + = new LRUMap(16, 120); /** * Cache for resolved endpoint configurations when writing JSON data */ protected final LRUMap _writers - = new LRUMap(16, 120); + = new LRUMap(16, 120); /* /********************************************************** @@ -217,7 +217,7 @@ protected ProviderBase() { _mapperConfig = null; _jaxRSFeatures = JAXRS_FEATURE_DEFAULTS; } - + /* /********************************************************** /* Configuring @@ -241,7 +241,7 @@ protected ProviderBase() { /** * Method for marking specified type as "untouchable", meaning that provider * will not try to read or write values of this type (or its subtypes). - * + * * @param type Type to consider untouchable; can be any kind of class, * including abstract class or interface. No instance of this type * (including subtypes, i.e. types assignable to this type) will @@ -257,8 +257,8 @@ public void addUntouchable(Class type) /** * Method for removing definition of specified type as untouchable: - * usually only - * + * usually only + * * @since 2.2 */ public void removeUntouchable(Class type) @@ -268,19 +268,19 @@ public void removeUntouchable(Class type) } _cfgCustomUntouchables.put(new ClassKey(type), Boolean.FALSE); } - + /** * Method for configuring which annotation sets to use (including none). * Annotation sets are defined in order decreasing precedence; that is, * first one has the priority over following ones. - * + * * @param annotationsToUse Ordered list of annotation sets to use; if null, * default */ public void setAnnotationsToUse(Annotations[] annotationsToUse) { _mapperConfig.setAnnotationsToUse(annotationsToUse); } - + /** * Method that can be used to directly define {@link ObjectMapper} to use * for serialization and deserialization; if null, will use the standard @@ -293,7 +293,7 @@ public void setMapper(MAPPER m) { /** * Method for specifying JSON View to use for reading content * when end point does not have explicit View annotations. - * + * * @since 2.3 */ public THIS setDefaultReadView(Class view) { @@ -304,7 +304,7 @@ public THIS setDefaultReadView(Class view) { /** * Method for specifying JSON View to use for reading content * when end point does not have explicit View annotations. - * + * * @since 2.3 */ public THIS setDefaultWriteView(Class view) { @@ -320,16 +320,16 @@ public THIS setDefaultWriteView(Class view) { * setDefaultReadView(view); * setDefaultWriteView(view); * - * + * * @since 2.3 */ public THIS setDefaultView(Class view) { _defaultReadView = _defaultWriteView = view; return _this(); } - + // // // JaxRSFeature config - + public THIS configure(JaxRSFeature feature, boolean state) { return state ? enable(feature) : disable(feature); } @@ -363,14 +363,14 @@ public THIS disable(JaxRSFeature first, JaxRSFeature... f2) { public boolean isEnabled(JaxRSFeature f) { return (_jaxRSFeatures & f.getMask()) != 0; } - + // // // DeserializationFeature public THIS configure(DeserializationFeature f, boolean state) { _mapperConfig.configure(f, state); return _this(); } - + public THIS enable(DeserializationFeature f) { _mapperConfig.configure(f, true); return _this(); @@ -380,7 +380,7 @@ public THIS disable(DeserializationFeature f) { _mapperConfig.configure(f, false); return _this(); } - + // // // SerializationFeature public THIS configure(SerializationFeature f, boolean state) { @@ -397,9 +397,9 @@ public THIS disable(SerializationFeature f) { _mapperConfig.configure(f, false); return _this(); } - + // // // JsonParser/JsonGenerator - + public THIS enable(JsonParser.Feature f) { _mapperConfig.configure(f, true); return _this(); @@ -442,7 +442,7 @@ public THIS configure(JsonGenerator.Feature f, boolean state) { * (when binding input data such as POST body). *

* Default implementation simply calls {@link #hasMatchingMediaType}. - * + * * @since 2.3 */ protected boolean hasMatchingMediaTypeForReading(MediaType mediaType) { @@ -456,17 +456,17 @@ protected boolean hasMatchingMediaTypeForReading(MediaType mediaType) { * body of request (like GET or POST). *

* Default implementation simply calls {@link #hasMatchingMediaType}. - * + * * @since 2.3 */ protected boolean hasMatchingMediaTypeForWriting(MediaType mediaType) { return hasMatchingMediaType(mediaType); } - + /** * Helper method used to check whether given media type * is supported by this provider. - * + * * @since 2.2 */ protected abstract boolean hasMatchingMediaType(MediaType mediaType); @@ -475,9 +475,9 @@ protected boolean hasMatchingMediaTypeForWriting(MediaType mediaType) { * Helper method that is called if no mapper has been explicitly configured. */ protected abstract MAPPER _locateMapperViaProvider(Class type, MediaType mediaType); - + protected EP_CONFIG _configForReading(MAPPER mapper, - Annotation[] annotations, Class defaultView) + Annotation[] annotations, Class defaultView) { // ObjectReader r = _readerInjector.getAndClear(); ObjectReader r; @@ -490,7 +490,7 @@ protected EP_CONFIG _configForReading(MAPPER mapper, } protected EP_CONFIG _configForWriting(MAPPER mapper, - Annotation[] annotations, Class defaultView) + Annotation[] annotations, Class defaultView) { // ObjectWriter w = _writerInjector.getAndClear(); ObjectWriter w; @@ -503,10 +503,10 @@ protected EP_CONFIG _configForWriting(MAPPER mapper, } protected abstract EP_CONFIG _configForReading(ObjectReader reader, - Annotation[] annotations); + Annotation[] annotations); protected abstract EP_CONFIG _configForWriting(ObjectWriter writer, - Annotation[] annotations); + Annotation[] annotations); /* /********************************************************** @@ -530,7 +530,7 @@ public long getSize(Object value, Class type, Type genericType, Annotation[] */ return -1; } - + /** * Method that JAX-RS container calls to try to check whether * given value (of specified type) can be serialized by @@ -669,9 +669,9 @@ protected JsonEncoding findEncoding(MediaType mediaType, MultivaluedMap type, Type genericType, Annotation[] annotations, - MultivaluedMap httpHeaders, - EP_CONFIG endpoint) - throws IOException + MultivaluedMap httpHeaders, + EP_CONFIG endpoint) + throws IOException { // Add "nosniff" header? if (isEnabled(JaxRSFeature.ADD_NO_SNIFF_HEADER)) { @@ -682,7 +682,7 @@ protected void _modifyHeaders(Object value, Class type, Type genericType, Ann /** * Overridable helper method called to create a {@link JsonGenerator} for writing * contents into given raw {@link OutputStream}. - * + * * @since 2.3 */ protected JsonGenerator _createGenerator(ObjectWriter writer, OutputStream rawStream, JsonEncoding enc) @@ -778,16 +778,16 @@ public boolean isReadable(Class type, Type genericType, Annotation[] annotati */ @Override public Object readFrom(Class type, Type genericType, Annotation[] annotations, - MediaType mediaType, MultivaluedMap httpHeaders, - InputStream entityStream) - throws IOException + MediaType mediaType, MultivaluedMap httpHeaders, + InputStream entityStream) + throws IOException { EP_CONFIG endpoint = _endpointForReading(type, genericType, annotations, mediaType, httpHeaders); - + ObjectReader reader = endpoint.getReader(); JsonParser p = _createParser(reader, entityStream); - + // If null is returned, considered to be empty stream // 05-Apr-2014, tatu: As per [Issue#49], behavior here is configurable. if (p == null || p.nextToken() == null) { @@ -809,7 +809,7 @@ public Object readFrom(Class type, Type genericType, Annotation[] annota // 09-Jul-2015, tatu: As per [jaxrs-providers#69], handle MappingIterator too boolean multiValued = (rawType == MappingIterator.class); - + if (multiValued) { JavaType[] contents = tf.findTypeParameters(resolvedType, MappingIterator.class); JavaType valueType = (contents == null || contents.length == 0) @@ -824,7 +824,7 @@ public Object readFrom(Class type, Type genericType, Annotation[] annota if (mod != null) { reader = mod.modify(endpoint, httpHeaders, resolvedType, reader, p); } - + if (multiValued) { return reader.readValues(p); } @@ -836,11 +836,11 @@ public Object readFrom(Class type, Type genericType, Annotation[] annota * contents of given raw {@link InputStream}. * May return null to indicate that Stream is empty; that is, contains no * content. - * + * * @since 2.2 */ protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) - throws IOException + throws IOException { JsonParser p = reader.getFactory().createParser(rawStream); // Important: we are NOT to close the underlying stream after @@ -857,7 +857,7 @@ protected JsonParser _createParser(ObjectReader reader, InputStream rawStream) * @since 2.8 */ protected EP_CONFIG _endpointForReading(Class type, Type genericType, Annotation[] annotations, - MediaType mediaType, MultivaluedMap httpHeaders) + MediaType mediaType, MultivaluedMap httpHeaders) { // 29-Jun-2016, tatu: As per [jaxrs-providers#86] allow skipping caching if (!isEnabled(JaxRSFeature.CACHE_ENDPOINT_READERS)) { @@ -891,7 +891,7 @@ protected EP_CONFIG _endpointForReading(Class type, Type genericType, An * Method called to locate {@link ObjectMapper} to use for serialization * and deserialization. Exact logic depends on setting of * {@link JaxRSFeature#DYNAMIC_OBJECT_MAPPER_LOOKUP}. - * + * *

* If {@link JaxRSFeature#DYNAMIC_OBJECT_MAPPER_LOOKUP} is disabled (default * setting unless changed), behavior is as follows: @@ -938,7 +938,7 @@ public MAPPER locateMapper(Class type, MediaType mediaType) // Otherwise start with (pre-)configured Mapper and only check provider // if not found - + MAPPER m = _mapperConfig.getConfiguredMapper(); if (m == null) { // If not, maybe we can get one configured via context? @@ -954,7 +954,7 @@ public MAPPER locateMapper(Class type, MediaType mediaType) /** * Overridable helper method used to allow handling of somewhat special * types for reading - * + * * @since 2.2 */ protected boolean _isSpecialReadable(Class type) { @@ -1030,7 +1030,7 @@ protected Boolean _findCustomUntouchable(Class mainType) } return null; } - + protected static List> findSuperTypes(Class cls, Class endBefore) { return findSuperTypes(cls, endBefore, new ArrayList>(8)); @@ -1041,7 +1041,7 @@ protected static List> findSuperTypes(Class cls, Class endBefore, _addSuperTypes(cls, endBefore, result, false); return result; } - + protected static void _addSuperTypes(Class cls, Class endBefore, Collection> result, boolean addClassItself) { if (cls == endBefore || cls == null || cls == Object.class) { @@ -1063,4 +1063,4 @@ protected static void _addSuperTypes(Class cls, Class endBefore, Collectio private final THIS _this() { return (THIS) this; } -} +} \ No newline at end of file diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/AnnotationBundleKey.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/AnnotationBundleKey.java index 79157f1eb6..cd991bffd5 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/AnnotationBundleKey.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/AnnotationBundleKey.java @@ -13,7 +13,7 @@ public final class AnnotationBundleKey { private final static Annotation[] NO_ANNOTATIONS = new Annotation[0]; - + private final Annotation[] _annotations; /** @@ -23,7 +23,7 @@ public final class AnnotationBundleKey * not mapper or reader/writer). */ private final Class _type; - + private final boolean _annotationsCopied; private final int _hashCode; @@ -70,7 +70,7 @@ private final static int calcHash(Annotation[] annotations) } return hash; } - + /** * Method called to create a safe immutable copy of the key; used when * adding entry with this key -- lookups are ok without calling the method. @@ -95,7 +95,7 @@ public AnnotationBundleKey immutableKey() { public int hashCode() { return _hashCode; } - + @Override public String toString() { return "[Annotations: "+_annotations.length+", type: " @@ -115,7 +115,7 @@ public boolean equals(Object o) } return _equals(other._annotations); } - + private final boolean _equals(Annotation[] otherAnn) { final int len = _annotations.length; @@ -128,32 +128,35 @@ private final boolean _equals(Annotation[] otherAnn) // possible permutations but rather trying to ensure that caching of same // method signature is likely to match. So false negatives are acceptable // over having to do order-insensitive comparison. - + + // 25-Oct-2021, tatu: But note that there is balance here; the goal is NOT + // 100% accuracy (every equal combination found as such) but finding + // some matches, efficiently, while allowing no false matches. switch (len) { - default: - for (int i = 0; i < len; ++i) { - if (!_annotations[i].equals(otherAnn[i])) { + default: + for (int i = 0; i < len; ++i) { + if (!_annotations[i].equals(otherAnn[i])) { + return false; + } + } + return true; + + case 3: + if (!_annotations[2].equals(otherAnn[2])) { + return false; + } + // fall through + case 2: + if (!_annotations[1].equals(otherAnn[1])) { + return false; + } + // fall through + case 1: + if (!_annotations[0].equals(otherAnn[0])) { return false; } - } - return true; - - case 3: - if (!_annotations[2].equals(otherAnn[2])) { - return false; - } - // fall through - case 2: - if (!_annotations[1].equals(otherAnn[1])) { - return false; - } - // fall through - case 1: - if (!_annotations[0].equals(otherAnn[0])) { - return false; - } - // fall through - case 0: + // fall through + case 0: } return true; } diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/PackageVersion.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/PackageVersion.java index 0389a9c3a5..86f1fad8f6 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/PackageVersion.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/PackageVersion.java @@ -11,7 +11,7 @@ */ public final class PackageVersion implements Versioned { public final static Version VERSION = VersionUtil.parseVersion( - "2.13.3", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); + "2.14.1", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); @Override public Version version() { diff --git a/media/json-jackson/src/main/resources/META-INF/NOTICE.markdown b/media/json-jackson/src/main/resources/META-INF/NOTICE.markdown index f35a86b462..e08c16d621 100644 --- a/media/json-jackson/src/main/resources/META-INF/NOTICE.markdown +++ b/media/json-jackson/src/main/resources/META-INF/NOTICE.markdown @@ -31,7 +31,7 @@ The project maintains the following source code repositories: ## Third-party Content -Jackson JAX-RS Providers version 2.13.3 +Jackson JAX-RS Providers version 2.14.1 * License: Apache License, 2.0 * Project: https://github.com/FasterXML/jackson-jaxrs-providers * Copyright: (c) 2009-2022 FasterXML, LLC. All rights reserved unless otherwise indicated. diff --git a/pom.xml b/pom.xml index 6ec89e2a86..41d49f01c6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@