From c5bef6a062ce30338e1d7b3bc3437b4b84afad7c Mon Sep 17 00:00:00 2001 From: Jan Supol Date: Thu, 14 Nov 2019 21:47:09 +0100 Subject: [PATCH 1/2] Updated Jackson to 2.10.1 Signed-off-by: Jan Supol --- .../jaxrs/annotation/JacksonFeatures.java | 2 +- .../base/JsonMappingExceptionMapper.java | 3 +- .../jaxrs/base/JsonParseExceptionMapper.java | 3 +- .../jackson/jaxrs/base/ProviderBase.java | 11 ++--- .../jaxrs/cfg/AnnotationBundleKey.java | 34 +++++++++++++-- .../jackson/jaxrs/cfg/EndpointConfigBase.java | 5 --- .../jaxrs/json/JacksonJsonProvider.java | 8 ---- .../jaxrs/json/JsonEndpointConfig.java | 11 ----- .../jackson/jaxrs/json/PackageVersion.java | 2 +- .../json/annotation/JacksonFeatures.java | 42 ------------------- .../jaxrs/util/EndpointAsBeanProperty.java | 5 ++- pom.xml | 2 +- 12 files changed, 43 insertions(+), 85 deletions(-) delete mode 100644 media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/annotation/JacksonFeatures.java diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/annotation/JacksonFeatures.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/annotation/JacksonFeatures.java index 8b7931999e..c1d0475d47 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/annotation/JacksonFeatures.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/annotation/JacksonFeatures.java @@ -12,7 +12,7 @@ * Annotation that can be used enable and/or disable various * features for ObjectReaders and ObjectWriters. */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD }) +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.PARAMETER }) @Retention(RetentionPolicy.RUNTIME) @com.fasterxml.jackson.annotation.JacksonAnnotation public @interface JacksonFeatures diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonMappingExceptionMapper.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonMappingExceptionMapper.java index 7ccfd3d152..25e13e5da2 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonMappingExceptionMapper.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonMappingExceptionMapper.java @@ -1,10 +1,9 @@ package org.glassfish.jersey.jackson.internal.jackson.jaxrs.base; +import com.fasterxml.jackson.databind.JsonMappingException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; -import com.fasterxml.jackson.databind.JsonMappingException; - /** * Implementation if {@link ExceptionMapper} to send down a "400 Bad Request" * response in the event that unmappable JSON is received. diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonParseExceptionMapper.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonParseExceptionMapper.java index 9f8d55f31d..4be9aa5594 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonParseExceptionMapper.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/base/JsonParseExceptionMapper.java @@ -1,10 +1,9 @@ package org.glassfish.jersey.jackson.internal.jackson.jaxrs.base; +import com.fasterxml.jackson.core.JsonParseException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; -import com.fasterxml.jackson.core.JsonParseException; - /** * Implementation of {@link ExceptionMapper} to send down a "400 Bad Request" * in the event unparsable JSON is received. 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 170e0f8523..e42e163571 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 @@ -83,10 +83,9 @@ public abstract class ProviderBase< // then some primitive types DEFAULT_UNTOUCHABLES.add(new ClassKey(char[].class)); - /* 27-Apr-2012, tatu: Ugh. As per - * [https://github.com/FasterXML/jackson-jaxrs-json-provider/issues/12] - * better revert this back, to make them untouchable again. - */ + // 27-Apr-2012, tatu: Ugh. As per + // [https://github.com/FasterXML/jackson-jaxrs-json-provider/issues/12] + // better revert this back, to make them untouchable again. DEFAULT_UNTOUCHABLES.add(new ClassKey(String.class)); DEFAULT_UNTOUCHABLES.add(new ClassKey(byte[].class)); } @@ -997,9 +996,7 @@ protected boolean _isIgnorableForWriting(ClassKey typeKey) */ protected IOException _createNoContentException() { - // 29-Jun-2016, tatu: With Jackson 2.8 we require JAX-RS 2.0 so this - // is fine; earlier had complicated Reflection-based access - return new NoContentException("No content (empty input stream)"); + return new NoContentException("No content (empty input stream)"); } /* 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 854a7edee9..79157f1eb6 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 @@ -122,11 +122,39 @@ private final boolean _equals(Annotation[] otherAnn) if (otherAnn.length != len) { return false; } - for (int i = 0; i < len; ++i) { - if (_annotations[i] != otherAnn[i]) { + + // 05-May-2019, tatu: If we wanted to true equality of contents we should + // do order-insensitive check; however, our use case is not unifying all + // 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. + + switch (len) { + 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; } + // fall through + case 0: } return true; } -} +} \ No newline at end of file diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/EndpointConfigBase.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/EndpointConfigBase.java index afc8e1aaf4..c48b5971ba 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/EndpointConfigBase.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/cfg/EndpointConfigBase.java @@ -54,11 +54,6 @@ protected EndpointConfigBase(MapperConfig config) { _config = config; } - @Deprecated // since 2.6 - protected EndpointConfigBase() { - _config = null; - } - @SuppressWarnings("unchecked") protected THIS add(Annotation[] annotations, boolean forWriting) { 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 d766495894..dc5fff8510 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 @@ -231,12 +231,4 @@ protected JsonEndpointConfig _configForWriting(ObjectWriter writer, return JsonEndpointConfig.forWriting(writer, annotations, _jsonpFunctionName); } - - /** - * @deprecated Since 2.2 use {@link #hasMatchingMediaType(MediaType)} instead - */ - @Deprecated - protected boolean isJsonType(MediaType mediaType) { - return hasMatchingMediaType(mediaType); - } } diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JsonEndpointConfig.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JsonEndpointConfig.java index 5a4d9a68e8..cbe0b58942 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JsonEndpointConfig.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/JsonEndpointConfig.java @@ -4,7 +4,6 @@ import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.EndpointConfigBase; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.annotation.JSONP; -import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.annotation.JacksonFeatures; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectWriter; @@ -61,7 +60,6 @@ public static JsonEndpointConfig forWriting(ObjectWriter writer, /********************************************************** */ - @SuppressWarnings("deprecation") @Override protected void addAnnotation(Class type, Annotation annotation, boolean forWriting) @@ -70,15 +68,6 @@ protected void addAnnotation(Class type, if (forWriting) { _jsonp = new JSONP.Def((JSONP) annotation); } - } else if (type == JacksonFeatures.class) { - JacksonFeatures feats = (JacksonFeatures) annotation; - if (forWriting) { - _serEnable = nullIfEmpty(feats.serializationEnable()); - _serDisable = nullIfEmpty(feats.serializationDisable()); - } else { - _deserEnable = nullIfEmpty(feats.deserializationEnable()); - _deserDisable = nullIfEmpty(feats.deserializationDisable()); - } } else { super.addAnnotation(type, annotation, forWriting); } 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 05d75b9060..46376a4619 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.8.4", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); + "2.10.1", "com.fasterxml.jackson.jaxrs", "jackson-jaxrs-json-provider"); @Override public Version version() { diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/annotation/JacksonFeatures.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/annotation/JacksonFeatures.java deleted file mode 100644 index 483107a9ef..0000000000 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/json/annotation/JacksonFeatures.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.SerializationFeature; - -/** - * Annotation that can be used enable and/or disable various - * features for ObjectReaders and ObjectWriters. - * - * @deprecated Since 2.2, use shared {@link com.fasterxml.jackson.jaxrs.annotation.JacksonFeatures} instead - */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD }) -@Retention(RetentionPolicy.RUNTIME) -@com.fasterxml.jackson.annotation.JacksonAnnotation -@Deprecated // since 2.2 -public @interface JacksonFeatures -{ - /** - * Deserialization features to enable. - */ - public DeserializationFeature[] deserializationEnable() default { }; - - /** - * Deserialization features to disable. - */ - public DeserializationFeature[] deserializationDisable() default { }; - - /** - * Serialization features to enable. - */ - public SerializationFeature[] serializationEnable() default { }; - - /** - * Serialization features to disable. - */ - public SerializationFeature[] serializationDisable() default { }; -} diff --git a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/util/EndpointAsBeanProperty.java b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/util/EndpointAsBeanProperty.java index 89ed89a20c..876a708c8d 100644 --- a/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/util/EndpointAsBeanProperty.java +++ b/media/json-jackson/src/main/java/org/glassfish/jersey/jackson/internal/jackson/jaxrs/util/EndpointAsBeanProperty.java @@ -16,11 +16,12 @@ * limitations, we are only given annotations associated, and that * has to do. *

- * NOTE: not yet used by JAX-RS provider, directly, as of Jackson 2.6. + * NOTE: not yet used by JAX-RS provider, directly, as of Jackson 2.9 */ public class EndpointAsBeanProperty extends BeanProperty.Std { + private static final long serialVersionUID = 1L; public final static PropertyName ENDPOINT_NAME = new PropertyName("JAX-RS/endpoint"); private final static AnnotationMap NO_ANNOTATIONS = new AnnotationMap(); @@ -33,7 +34,7 @@ public EndpointAsBeanProperty(PropertyName name, JavaType type, Annotation[] ann { // TODO: find and pass wrapper; isRequired marker? super(name, type, /*PropertyName wrapperName*/ null, - null, null, PropertyMetadata.STD_OPTIONAL); + null, PropertyMetadata.STD_OPTIONAL); _rawAnnotations = annotations; _annotations = null; } diff --git a/pom.xml b/pom.xml index 871a403468..433c13610d 100644 --- a/pom.xml +++ b/pom.xml @@ -2082,7 +2082,7 @@ 5.1.0 4.5.9 3.0.8 - 2.9.9 + 2.10.1 1.9.13 1.2.1 3.25.0-GA From 62c3825c58974fc455f3fec5a7406c6292f3fc12 Mon Sep 17 00:00:00 2001 From: jansupol Date: Sat, 7 Dec 2019 06:25:56 +0100 Subject: [PATCH 2/2] Fix OSgi Tests Signed-off-by: jansupol --- tests/osgi/functional/pom.xml | 13 +++++++------ .../org/glassfish/jersey/osgi/test/util/Helper.java | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/osgi/functional/pom.xml b/tests/osgi/functional/pom.xml index 83b9b08c25..22598ed549 100644 --- a/tests/osgi/functional/pom.xml +++ b/tests/osgi/functional/pom.xml @@ -376,12 +376,13 @@ jakarta.xml.bind-api test - - com.sun.activation - jakarta.activation - ${jakarta.activation.version} - test - + + + + + + + diff --git a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java index 9108cd6807..c334e7102b 100644 --- a/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java +++ b/tests/osgi/functional/src/test/java/org/glassfish/jersey/osgi/test/util/Helper.java @@ -168,9 +168,10 @@ public static List