From 5636ea0d18a4831f4ebcd3f8de72a67549ca16b8 Mon Sep 17 00:00:00 2001 From: Nicolas Dos Santos Date: Sat, 21 Sep 2024 16:42:08 +0200 Subject: [PATCH] [serializer] Bump jackson version and fix JsonLdTypeFactory constructor #145 --- .../SchemaDefinitionReaderImplTest.java | 21 ++++++++++++------- maven-plugin/pom.xml | 4 ++-- pom.xml | 2 +- .../deserialization/JsonLdTypeFactory.java | 5 ++--- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/generator/src/test/java/com/weedow/schemaorg/generator/reader/SchemaDefinitionReaderImplTest.java b/generator/src/test/java/com/weedow/schemaorg/generator/reader/SchemaDefinitionReaderImplTest.java index 24d60cd5..5dce3b6d 100644 --- a/generator/src/test/java/com/weedow/schemaorg/generator/reader/SchemaDefinitionReaderImplTest.java +++ b/generator/src/test/java/com/weedow/schemaorg/generator/reader/SchemaDefinitionReaderImplTest.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; import static com.weedow.schemaorg.generator.model.handler.ModelHandlerTestUtils.*; import static java.util.Map.entry; @@ -63,11 +62,17 @@ void read() throws SchemaDefinitionReaderException { "schema:OriginalMediaContent", List.of("schema:MediaManipulationRatingEnumeration"), comment("en", - "Content coded 'as original media content' in a [[MediaReview]], considered in the context of how it was published or shared.\n\n" + - "For a [[VideoObject]] to be 'original': No evidence the footage has been misleadingly altered or manipulated, though it may contain false or misleading claims.\n\n" + - "For an [[ImageObject]] to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.\n\n" + - "For an [[ImageObject]] with embedded text to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.\n\n" + - "For an [[AudioObject]] to be 'original': No evidence the audio has been misleadingly altered or manipulated, though it may contain false or misleading claims.\n" + """ + Content coded 'as original media content' in a [[MediaReview]], considered in the context of how it was published or shared. + + For a [[VideoObject]] to be 'original': No evidence the footage has been misleadingly altered or manipulated, though it may contain false or misleading claims. + + For an [[ImageObject]] to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims. + + For an [[ImageObject]] with embedded text to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims. + + For an [[AudioObject]] to be 'original': No evidence the audio has been misleadingly altered or manipulated, though it may contain false or misleading claims. + """ ), label("en", "OriginalMediaContent"), null, null, null, null, List.of(partOf("https://pending.schema.org")), List.of(source("https://github.com/schemaorg/schemaorg/issues/2450")) @@ -229,10 +234,10 @@ void throw_exception_when_read_invalid_jsonld() { Assertions.assertThatThrownBy(() -> schemaDefinitionReader.read(getClass().getResourceAsStream("/data/invalid-schemaorg.jsonld"))) .isInstanceOf(SchemaDefinitionReaderException.class) .hasMessage("Could not read the JSON schema definition: Unrecognized token 'invalid': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" + - " at [Source: (String)\"invalid json\"; line: 1, column: 8]"); + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 8]"); } private static List filter(SchemaDefinition schemaDefinition, Predicate predicate) { - return schemaDefinition.getGraph().stream().filter(predicate).collect(Collectors.toList()); + return schemaDefinition.getGraph().stream().filter(predicate).toList(); } } \ No newline at end of file diff --git a/maven-plugin/pom.xml b/maven-plugin/pom.xml index ce9cc0a4..f8a52bc8 100644 --- a/maven-plugin/pom.xml +++ b/maven-plugin/pom.xml @@ -168,10 +168,10 @@ 3.2.5 - + ${maven.version} ${maven.home} - + diff --git a/pom.xml b/pom.xml index 8492298c..e1e6eba6 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ 1.18.26 1.5.6 - 2.15.0 + 2.17.2 4.3.1 1.5.0 diff --git a/serializer/src/main/java/com/weedow/schemaorg/serializer/deserialization/JsonLdTypeFactory.java b/serializer/src/main/java/com/weedow/schemaorg/serializer/deserialization/JsonLdTypeFactory.java index f6e0675c..ad83972a 100644 --- a/serializer/src/main/java/com/weedow/schemaorg/serializer/deserialization/JsonLdTypeFactory.java +++ b/serializer/src/main/java/com/weedow/schemaorg/serializer/deserialization/JsonLdTypeFactory.java @@ -1,8 +1,7 @@ package com.weedow.schemaorg.serializer.deserialization; -import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.type.TypeFactory; -import com.fasterxml.jackson.databind.util.LookupCache; +import com.fasterxml.jackson.databind.util.LRUMap; import com.weedow.schemaorg.commons.generator.GeneratorConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,7 +20,7 @@ public class JsonLdTypeFactory extends TypeFactory { private final Map> types = new HashMap<>(); public JsonLdTypeFactory(Map> otherTypes) { - super((LookupCache) null); + super(new LRUMap<>(16, DEFAULT_MAX_CACHE_SIZE)); try (InputStream schemaOrgJavaProperties = Thread.currentThread().getContextClassLoader().getResourceAsStream(GeneratorConstants.SCHEMA_ORG_PROP_FILENAME)) { Properties properties = new Properties();