diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroMessageConverterAutoConfiguration.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroMessageConverterAutoConfiguration.java index b36686ec3..a6231d496 100644 --- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroMessageConverterAutoConfiguration.java +++ b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroMessageConverterAutoConfiguration.java @@ -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); diff --git a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroSchemaRegistryClientMessageConverter.java b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroSchemaRegistryClientMessageConverter.java index 30872edc3..91f130046 100644 --- a/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroSchemaRegistryClientMessageConverter.java +++ b/spring-cloud-stream-schema/src/main/java/org/springframework/cloud/stream/schema/avro/AvroSchemaRegistryClientMessageConverter.java @@ -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 _headers = (Map) 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; } diff --git a/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/AvroSchemaRegistryClientMessageConverterTests.java b/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/AvroSchemaRegistryClientMessageConverterTests.java index e64537b28..d89b7767e 100644 --- a/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/AvroSchemaRegistryClientMessageConverterTests.java +++ b/spring-cloud-stream-schema/src/test/java/org/springframework/cloud/schema/avro/AvroSchemaRegistryClientMessageConverterTests.java @@ -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()); } } }