Skip to content

Commit

Permalink
Fix CCE with Map parameterized types
Browse files Browse the repository at this point in the history
Fixes: #25073
  • Loading branch information
geoand committed Apr 22, 2022
1 parent 0c1ad3b commit 4ba87a1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,36 @@ static Stream<Map.Entry<String, String>> testStreamOfMapEntryArguments() {
static class TestData {
final List<String> foo = Arrays.asList("one", "two", "three");
}

static Stream<Arguments> arguments() {
return Stream.of(
Arguments.of(new TestObject1()),
Arguments.of(new TestObject2()));
}

@ParameterizedTest
@MethodSource("arguments")
void map(Object o) {

}

static class TestObject1 {

private final Map<String, String> map = Collections.emptyMap();

Map<String, String> getMap() {
return map;
}

}

static class TestObject2 {

private final Map<String, String> map = Map.of();

Map<String, String> getMap() {
return map;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Map;
import java.util.Set;

import com.thoughtworks.xstream.converters.collections.CollectionConverter;
import com.thoughtworks.xstream.converters.collections.MapConverter;
import com.thoughtworks.xstream.mapper.Mapper;

/**
Expand All @@ -16,7 +16,7 @@
* The reason for doing this is to avoid XStream causing illegal access issues
* for internal JDK maps
*/
public class CustomMapConverter extends CollectionConverter {
public class CustomMapConverter extends MapConverter {

// if we wanted to be 100% sure, we'd list all the Set.of methods, but I think it's pretty safe to say
// that the JDK won't add custom implementations for the other classes
Expand Down

0 comments on commit 4ba87a1

Please sign in to comment.