@@ -98,9 +98,9 @@ public static boolean isStringable(AnnotatedClass type) {
98
98
return false ;
99
99
}
100
100
101
- protected static String getNamespace (BeanDescription bean ) {
102
- AvroNamespace ann = bean . getClassInfo () .getAnnotation (AvroNamespace .class );
103
- return ann != null ? ann .value () : getNamespace (bean . getType () .getRawClass ());
101
+ protected static String getNamespace (JavaType type , AnnotatedClass annotations ) {
102
+ AvroNamespace ann = annotations .getAnnotation (AvroNamespace .class );
103
+ return ann != null ? ann .value () : getNamespace (type .getRawClass ());
104
104
}
105
105
106
106
protected static String getNamespace (Class <?> cls ) {
@@ -243,11 +243,12 @@ protected static <T> T throwUnsupported() {
243
243
* needs to have fields added to it.
244
244
*/
245
245
public static Schema initializeRecordSchema (BeanDescription bean ) {
246
+ final JavaType beanType = bean .getType ();
246
247
return addAlias (Schema .createRecord (
247
- getName (bean . getType () ),
248
+ getName (beanType ),
248
249
bean .findClassDescription (),
249
- getNamespace (bean ),
250
- bean . getType () .isTypeOrSubTypeOf (Throwable .class )
250
+ getNamespace (beanType , bean . getClassInfo () ),
251
+ beanType .isTypeOrSubTypeOf (Throwable .class )
251
252
), bean );
252
253
}
253
254
@@ -267,10 +268,11 @@ public static Schema parseJsonSchema(String json) {
267
268
* @return An {@link org.apache.avro.Schema.Type#ENUM ENUM} schema.
268
269
*/
269
270
public static Schema createEnumSchema (BeanDescription bean , List <String > values ) {
271
+ final JavaType enumType = bean .getType ();
270
272
return addAlias (Schema .createEnum (
271
- getName (bean . getType () ),
273
+ getName (enumType ),
272
274
bean .findClassDescription (),
273
- getNamespace (bean ), values
275
+ getNamespace (enumType , bean . getClassInfo () ), values
274
276
), bean );
275
277
}
276
278
0 commit comments