Polishing AvroSchemaRegistry stuff
- removed deprecated constructor from AvroSchemaRegistryClientMessageConverter - fixed test - formatting Resolves #1221 #1218
This commit is contained in:
@@ -53,7 +53,7 @@ public class AvroMessageConverterAutoConfiguration {
|
||||
public AvroSchemaRegistryClientMessageConverter avroSchemaMessageConverter(
|
||||
SchemaRegistryClient schemaRegistryClient) {
|
||||
AvroSchemaRegistryClientMessageConverter avroSchemaRegistryClientMessageConverter = new AvroSchemaRegistryClientMessageConverter(
|
||||
schemaRegistryClient);
|
||||
schemaRegistryClient, cacheManager());
|
||||
avroSchemaRegistryClientMessageConverter.setDynamicSchemaGenerationEnabled(
|
||||
this.avroMessageConverterProperties.isDynamicSchemaGenerationEnabled());
|
||||
if (this.avroMessageConverterProperties.getReaderSchema() != null) {
|
||||
@@ -65,8 +65,7 @@ public class AvroMessageConverterAutoConfiguration {
|
||||
this.avroMessageConverterProperties.getSchemaLocations());
|
||||
}
|
||||
avroSchemaRegistryClientMessageConverter.setPrefix(this.avroMessageConverterProperties.getPrefix());
|
||||
avroSchemaRegistryClientMessageConverter.setCacheManager(cacheManager());
|
||||
|
||||
|
||||
try {
|
||||
Class clazz = this.avroMessageConverterProperties.getSubjectNamingStrategy();
|
||||
Constructor constructor = ReflectionUtils.accessibleConstructor(clazz);
|
||||
|
||||
@@ -88,7 +88,7 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
|
||||
public static final String REFERENCE_CACHE_NAME = CACHE_PREFIX + ".referenceCache";
|
||||
|
||||
public static final MimeType DEFAULT_AVRO_MIME_TYPE = new MimeType("application", "*+"+AVRO_FORMAT);
|
||||
public static final MimeType DEFAULT_AVRO_MIME_TYPE = new MimeType("application", "*+" + AVRO_FORMAT);
|
||||
|
||||
private Pattern versionedSchema;
|
||||
|
||||
@@ -106,15 +106,6 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
|
||||
private SubjectNamingStrategy subjectNamingStrategy;
|
||||
|
||||
/**
|
||||
* @deprecated as of release 1.2.2 in favor of
|
||||
* {@link #AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient, CacheManager)}
|
||||
*/
|
||||
@Deprecated
|
||||
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient) {
|
||||
this(schemaRegistryClient, new NoOpCacheManager());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance, configuring it with {@link SchemaRegistryClient} and
|
||||
* {@link CacheManager}.
|
||||
@@ -123,8 +114,7 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
* @param cacheManager instance of {@link CacheManager} to cache parsed schemas. If
|
||||
* caching is not required use {@link NoOpCacheManager}
|
||||
*/
|
||||
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient,
|
||||
CacheManager cacheManager) {
|
||||
public AvroSchemaRegistryClientMessageConverter(SchemaRegistryClient schemaRegistryClient, CacheManager cacheManager) {
|
||||
super(Collections.singletonList(DEFAULT_AVRO_MIME_TYPE));
|
||||
Assert.notNull(schemaRegistryClient, "cannot be null");
|
||||
Assert.notNull(cacheManager, "'cacheManager' cannot be null");
|
||||
@@ -259,7 +249,7 @@ public class AvroSchemaRegistryClientMessageConverter extends AbstractAvroMessag
|
||||
Map<String, Object> _headers = (Map<String, Object>) dfa.getPropertyValue("headers");
|
||||
_headers.put(MessageHeaders.CONTENT_TYPE,
|
||||
"application/" + this.prefix + "." + schemaReference.getSubject()
|
||||
+ ".v" + schemaReference.getVersion() + "+"+AVRO_FORMAT);
|
||||
+ ".v" + schemaReference.getVersion() + "+" + AVRO_FORMAT);
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 the original author or authors.
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -159,11 +159,10 @@ public class AvroSchemaRegistryClientMessageConverterTests {
|
||||
|
||||
@Configuration
|
||||
public static class NoCacheConfiguration {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Bean
|
||||
@StreamMessageConverter
|
||||
AvroSchemaRegistryClientMessageConverter avroSchemaRegistryClientMessageConverter() {
|
||||
return new AvroSchemaRegistryClientMessageConverter(new DefaultSchemaRegistryClient());
|
||||
return new AvroSchemaRegistryClientMessageConverter(new DefaultSchemaRegistryClient(), new NoOpCacheManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user