From 9c8628a9f249653e844f8d03d49ace97ac92be02 Mon Sep 17 00:00:00 2001 From: jansupol Date: Fri, 10 Dec 2021 00:15:40 +0100 Subject: [PATCH] Adopt Jackson 2.13 Signed-off-by: jansupol --- .../jackson/jaxrs/base/ProviderBase.java | 45 ++++++++----------- .../jackson/jaxrs/json/PackageVersion.java | 2 +- pom.xml | 2 +- 3 files changed, 20 insertions(+), 29 deletions(-) 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 e42e163571..d1e3d93447 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 @@ -63,6 +63,10 @@ public abstract class ProviderBase< */ public final static String HEADER_CONTENT_TYPE_OPTIONS = "X-Content-Type-Options"; + protected final static String CLASS_NAME_NO_CONTENT_EXCEPTION = "javax.ws.rs.core.NoContentException"; + + private final static String NO_CONTENT_MESSAGE = "No content (empty input stream)"; + /** * Looks like we need to worry about accidental * data binding for types we shouldn't be handling. This is @@ -192,9 +196,6 @@ public abstract class ProviderBase< protected final LRUMap _writers = new LRUMap(16, 120); - protected final AtomicReference _noContentExceptionRef - = new AtomicReference(); - /* /********************************************************** /* Life-cycle @@ -207,9 +208,8 @@ protected ProviderBase(MAPPER_CONFIG mconfig) { } /** - * Constructor that is only added to resolve - * issue #10; problems with combination of - * RESTeasy and CDI. + * Constructor that is only added to resolve [jaxrs-providers#10]; problems + * with combination of RESTeasy and CDI. * Should NOT be used by any code explicitly; only exists * for proxy support. */ @@ -554,9 +554,8 @@ public boolean isWriteable(Class type, Type genericType, Annotation[] annotat // negation: Boolean.TRUE means untouchable -> can not write return !customUntouchable.booleanValue(); } - /* Ok: looks like we must weed out some core types here; ones that - * make no sense to try to bind from JSON: - */ + // Ok: looks like we must weed out some core types here; ones that + // make no sense to try to bind from JSON: if (_isIgnorableForWriting(new ClassKey(type))) { return false; } @@ -751,9 +750,8 @@ public boolean isReadable(Class type, Type genericType, Annotation[] annotati // negation: Boolean.TRUE means untouchable -> can not write return !customUntouchable.booleanValue(); } - /* Ok: looks like we must weed out some core types here; ones that - * make no sense to try to bind from JSON: - */ + // Ok: looks like we must weed out some core types here; ones that + // make no sense to try to bind from JSON: if (_isIgnorableForReading(new ClassKey(type))) { return false; } @@ -797,14 +795,11 @@ public Object readFrom(Class type, Type genericType, Annotation[] annota if (JaxRSFeature.ALLOW_EMPTY_INPUT.enabledIn(_jaxRSFeatures)) { return null; } - /* 05-Apr-2014, tatu: Trick-ee. NoContentFoundException only available in JAX-RS 2.0... - * so need bit of obfuscated code to reach it. - */ - IOException fail = _noContentExceptionRef.get(); - if (fail == null) { - fail = _createNoContentException(); - } - throw fail; + // 05-Apr-2014, tatu: Trick-ee. NoContentFoundException only available in JAX-RS 2.0... + // so need bit of obfuscated code to reach it. + + // 20-Jan-2021, tatu: as per [jaxrs-providers#134], simplify + throw _createNoContentException(); } Class rawType = type; if (rawType == JsonParser.class) { @@ -990,13 +985,9 @@ protected boolean _isIgnorableForWriting(ClassKey typeKey) { return _untouchables.contains(typeKey); } - - /** - * @since 2.4 - */ - protected IOException _createNoContentException() - { - return new NoContentException("No content (empty input stream)"); + + protected IOException _createNoContentException() { + return new NoContentException(NO_CONTENT_MESSAGE); } /* 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 e8f885a50a..9974df6d93 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.11.3", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); + "2.13.0", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); @Override public Version version() { diff --git a/pom.xml b/pom.xml index ccc8e59c90..170803faca 100644 --- a/pom.xml +++ b/pom.xml @@ -2125,7 +2125,7 @@ org.jvnet.hk2.*;version="[2.5,4)" 5.1.0 4.5.13 - 2.12.2 + 2.13.0 1.9.13 3.25.0-GA 3.3.0.Final