diff --git a/kayenta-core/src/main/java/com/netflix/kayenta/config/KayentaConfiguration.java b/kayenta-core/src/main/java/com/netflix/kayenta/config/KayentaConfiguration.java index 18b6f6033..2fb97f411 100644 --- a/kayenta-core/src/main/java/com/netflix/kayenta/config/KayentaConfiguration.java +++ b/kayenta-core/src/main/java/com/netflix/kayenta/config/KayentaConfiguration.java @@ -108,18 +108,25 @@ public ObjectMapperSubtypeConfigurer.ClassSubtypeLocator assetSpecSubTypeLocator ImmutableList.of("com.netflix.kayenta.canary.providers.metrics")); } - @Primary @Bean - ObjectMapper kayentaObjectMapper(ObjectMapper mapper) { - return mapper; + @ConditionalOnMissingBean + public ObjectMapperSubtypeConfigurer objectMapperSubtypeConfigurer() { + return new ObjectMapperSubtypeConfigurer(true); } - @Autowired - public void objectMapper( + @Primary + @Bean + ObjectMapper kayentaObjectMapper( ObjectMapper mapper, + ObjectMapperSubtypeConfigurer objectMapperSubtypeConfigurer, List subtypeLocators, KayentaSerializationConfigurationProperties kayentaSerializationConfigurationProperties) { - configureObjectMapper(mapper, subtypeLocators, kayentaSerializationConfigurationProperties); + configureObjectMapper( + mapper, + objectMapperSubtypeConfigurer, + subtypeLocators, + kayentaSerializationConfigurationProperties); + return mapper; } public static void configureObjectMapperFeatures( @@ -141,9 +148,10 @@ public static void configureObjectMapperFeatures( private void configureObjectMapper( ObjectMapper objectMapper, + ObjectMapperSubtypeConfigurer objectMapperSubtypeConfigurer, List subtypeLocators, KayentaSerializationConfigurationProperties kayentaSerializationConfigurationProperties) { - new ObjectMapperSubtypeConfigurer(true).registerSubtypes(objectMapper, subtypeLocators); + objectMapperSubtypeConfigurer.registerSubtypes(objectMapper, subtypeLocators); configureObjectMapperFeatures(objectMapper, kayentaSerializationConfigurationProperties); }