From 4153611c0e892ab13355e365e5283dc59b94ee49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Jan 2023 23:06:46 +0000 Subject: [PATCH 1/2] Bump xstream from 1.4.19 to 1.4.20 Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.19 to 1.4.20. - [Release notes](https://github.com/x-stream/xstream/releases) - [Commits](https://github.com/x-stream/xstream/commits) --- updated-dependencies: - dependency-name: com.thoughtworks.xstream:xstream dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- test-framework/junit5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-framework/junit5/pom.xml b/test-framework/junit5/pom.xml index ce313d942dd9f..132c4db1b6531 100644 --- a/test-framework/junit5/pom.xml +++ b/test-framework/junit5/pom.xml @@ -52,7 +52,7 @@ com.thoughtworks.xstream xstream - 1.4.19 + 1.4.20 From b5234a3058054c6768bb0204e747b3dfd4e84303 Mon Sep 17 00:00:00 2001 From: Falko Modler Date: Thu, 5 Jan 2023 13:33:23 +0100 Subject: [PATCH 2/2] Remove custom XStream OptionalConverter in favor of the new OOTB one --- .../junit/internal/OptionalConverter.java | 52 ------------------- .../test/junit/internal/XStreamDeepClone.java | 3 -- 2 files changed, 55 deletions(-) delete mode 100644 test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/OptionalConverter.java diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/OptionalConverter.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/OptionalConverter.java deleted file mode 100644 index b3396fbca383b..0000000000000 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/OptionalConverter.java +++ /dev/null @@ -1,52 +0,0 @@ -package io.quarkus.test.junit.internal; - -import java.util.Optional; - -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.core.util.HierarchicalStreams; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.mapper.Mapper; - -public class OptionalConverter implements Converter { - private final Mapper mapper; - - public OptionalConverter(Mapper mapper) { - this.mapper = mapper; - } - - @Override - public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { - final Optional optional = (Optional) source; - - if (optional.isPresent()) { - Object item = optional.get(); - String name = mapper.serializedClass(item.getClass()); - - writer.startNode(name); - context.convertAnother(item); - writer.endNode(); - } else { - final String name = mapper.serializedClass(null); - writer.startNode(name); - writer.endNode(); - } - } - - @Override - public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { - reader.moveDown(); - final Class type = HierarchicalStreams.readClassType(reader, mapper); - Object item = context.convertAnother(null, type); - reader.moveUp(); - - return Optional.ofNullable(item); - } - - @Override - public boolean canConvert(Class type) { - return type == Optional.class; - } -} diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/XStreamDeepClone.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/XStreamDeepClone.java index 2310543d70397..9951f96734d44 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/XStreamDeepClone.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/XStreamDeepClone.java @@ -1,6 +1,5 @@ package io.quarkus.test.junit.internal; -import java.util.Optional; import java.util.function.Supplier; import com.thoughtworks.xstream.XStream; @@ -18,12 +17,10 @@ class XStreamDeepClone implements DeepClone { XStream result = new XStream(); result.allowTypesByRegExp(new String[] { ".*" }); result.setClassLoader(classLoader); - result.allowTypes(new Class[] { Optional.class }); result.registerConverter(new CustomListConverter(result.getMapper())); result.registerConverter(new CustomSetConverter(result.getMapper())); result.registerConverter(new CustomMapConverter(result.getMapper())); result.registerConverter(new CustomMapEntryConverter(result.getMapper())); - result.registerConverter(new OptionalConverter(result.getMapper())); return result; };