From 5bdc76dcd5989156a4a4f0af3915b3af08e37662 Mon Sep 17 00:00:00 2001 From: Nicolas Dos Santos Date: Sat, 21 Sep 2024 16:42:08 +0200 Subject: [PATCH 1/2] [serializer] Bump jackson version and fix JsonLdTypeFactory constructor #145 --- .../SchemaDefinitionReaderImplTest.java | 21 ++++++++++++------- maven-plugin/pom.xml | 4 ++-- pom.xml | 2 +- .../deserialization/JsonLdTypeFactory.java | 5 ++--- .../JsonLdDeserializerImplTest.java | 7 +++---- 5 files changed, 21 insertions(+), 18 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(); diff --git a/serializer/src/test/java/com/weedow/schemaorg/serializer/deserialization/JsonLdDeserializerImplTest.java b/serializer/src/test/java/com/weedow/schemaorg/serializer/deserialization/JsonLdDeserializerImplTest.java index f9977956..e2aa9983 100644 --- a/serializer/src/test/java/com/weedow/schemaorg/serializer/deserialization/JsonLdDeserializerImplTest.java +++ b/serializer/src/test/java/com/weedow/schemaorg/serializer/deserialization/JsonLdDeserializerImplTest.java @@ -21,7 +21,6 @@ import org.schema.model.datatype.*; import org.schema.model.impl.*; -import java.net.MalformedURLException; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; @@ -201,13 +200,13 @@ void throws_exception_when_deserialize_invalid_data() { Assertions.assertThatThrownBy(() -> jsonLdDeserializer.deserialize("{}")) .isInstanceOf(JsonLdException.class) .hasMessage("JSON-LD deserialization internal error: Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" + - " at [Source: (String)\"{}\"; line: 1, column: 2].") + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2].") .hasCauseInstanceOf(JsonMappingException.class) .hasMessage("JSON-LD deserialization internal error: Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" + - " at [Source: (String)\"{}\"; line: 1, column: 2].") + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2].") .hasRootCauseInstanceOf(InvalidTypeIdException.class) .hasRootCauseMessage("Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" + - " at [Source: (String)\"{}\"; line: 1, column: 2]"); + " at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]"); } @Test From 7059a680590d9845ce76b3231b2a88f782812909 Mon Sep 17 00:00:00 2001 From: Nicolas Dos Santos Date: Sun, 22 Sep 2024 19:34:00 +0200 Subject: [PATCH 2/2] [chore] Update CHANGELOG.md --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91fdb5f9..083d3df4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,29 @@ All notable changes to this project will be documented in this file. ### Changed +- ⚠️ **Breaking change: requires java 17 or newer** +- Bump jackson-bom from 2.14.2 to 2.17.2 +- Bump net.javacrumbs.json-unit:json-unit-assertj from 2.37.0 to 3.4.1 +- Bump de.jutzig:github-release-plugin from 1.4.0 to 1.6.0 +- Bump maven-it-extension.version from 0.12.0 to 0.13.1 +- Bump org.jacoco:jacoco-maven-plugin from 0.8.9 to 0.8.12 +- Bump junit-jupiter-engine.version from 5.9.3 to 5.11.0 +- Bump ch.qos.logback:logback-classic from 1.4.7 to 1.5.6 +- Bump org.apache.maven:maven-core from 3.9.1 to 3.9.7 +- Bump org.apache.maven:maven-plugin-api from 3.9.1 to 3.9.9 +- Bump org.apache.maven.plugins:maven-dependency-plugin from 3.5.0 to 3.8.0 +- Bump org.apache.maven.plugins:maven-site-plugin from 3.12.1 to 3.20.0 +- Bump org.apache.maven.plugins:maven-plugin-plugin from 3.8.1 to 3.15.0 +- Bump org.apache.maven.plugin-tools:maven-plugin-annotations from 3.8.2 to 3.13.0 +- Bump org.apache.maven.plugins:maven-assembly-plugin from 3.5.0 to 3.7.1 +- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.0.0 to 3.2.5 +- Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.0.0 to 3.2.5 +- Bump junit-jupiter-engine.version from 5.9.2 to 5.9.3 + ### Fixed +[serializer] Bump jackson version and fix JsonLdTypeFactory constructor [#145](https://github.com/Kobee1203/schema-org-java/issues/145) + ## [0.6.0] - 2023-04-23 ### Added