Skip to content

Commit

Permalink
Nested generics support for Structs
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenkrishna committed Dec 18, 2018
1 parent 800c823 commit d36a634
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ private static boolean needsCodec(ThriftFieldMetadata fieldMetadata)

private static ParameterizedType toCodecType(ThriftStructMetadata metadata)
{
String className = type(metadata.getStructClass()).getClassName();
String className = metadata.getStructType().getTypeName().replaceAll("[^a-zA-Z0-9]+", "_");
return typeFromPathName(PACKAGE + "/" + className + "Codec");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private ThriftType(ThriftStructMetadata structMetadata)
requireNonNull(structMetadata, "structMetadata is null");

this.protocolType = ThriftProtocolType.STRUCT;
this.javaType = structMetadata.getStructClass();
this.javaType = structMetadata.getStructType();
keyTypeReference = null;
valueTypeReference = null;
this.structMetadata = structMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,11 @@ public void testBeanGeneric()
bean.setGenericProperty("genericValue");

testRoundTripSerialize(new TypeToken<GenericThriftStructBean<String>>() {}, bean);

GenericThriftStructBean<Long> beanForLong = new GenericThriftStructBean<>();
beanForLong.setGenericProperty(123L);

testRoundTripSerialize(new TypeToken<GenericThriftStructBean<Long>>() {}, beanForLong);
}

@Test
Expand Down

0 comments on commit d36a634

Please sign in to comment.