-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#938 YAML Wire fails to unmarshall generic collection.
- Loading branch information
1 parent
a70bec9
commit 656d56e
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/test/java/net/openhft/chronicle/wire/Reproduce938Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package net.openhft.chronicle.wire; | ||
|
||
import net.openhft.chronicle.core.pool.ClassAliasPool; | ||
import org.junit.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class Reproduce938Test { | ||
@Test | ||
public void reproduce() { | ||
ClassAliasPool.CLASS_ALIASES.addAlias( | ||
Impl1.class, | ||
Impl2.class, | ||
GenericContainer.class | ||
); | ||
|
||
ContainerWithWorkaround<Impl1> containerWithWorkaround = new ContainerWithWorkaround<>(); | ||
containerWithWorkaround.collection.add(new Impl1()); | ||
String containerWithWorkaroundAsYaml = WireType.YAML_ONLY.asString(containerWithWorkaround); | ||
WireType.YAML_ONLY.fromString(containerWithWorkaroundAsYaml); | ||
|
||
GenericContainer<Impl1> genericContainer = new GenericContainer<>(); | ||
genericContainer.collection.add(new Impl1()); | ||
String genericContainerAsYaml = WireType.YAML_ONLY.asString(genericContainer); | ||
WireType.YAML_ONLY.fromString(genericContainerAsYaml); | ||
} | ||
|
||
static abstract class AbstractGeneric<T extends AbstractGeneric<T>> { | ||
private long value; | ||
|
||
public long value() { | ||
return value; | ||
} | ||
|
||
public T value(long i) { | ||
this.value = i; | ||
return (T) this; | ||
} | ||
} | ||
|
||
static class Impl1 extends AbstractGeneric<Impl1> { | ||
|
||
} | ||
|
||
static class Impl2 extends AbstractGeneric<Impl2> { | ||
|
||
} | ||
|
||
static class GenericContainer<T extends AbstractGeneric<T>> extends SelfDescribingMarshallable{ | ||
private Collection<T> collection = new ArrayList<>(); | ||
} | ||
|
||
static class ContainerWithWorkaround<T extends AbstractGeneric<T>> extends SelfDescribingMarshallable{ | ||
private Collection collection = new ArrayList<>(); | ||
} | ||
} |