diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java index 260559e8639..158c2cd0086 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -57,7 +57,6 @@ import com.fasterxml.jackson.dataformat.xml.XmlFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.springframework.beans.BeanUtils; -import org.springframework.beans.FatalBeanException; import org.springframework.context.ApplicationContext; import org.springframework.core.KotlinDetector; import org.springframework.http.ProblemDetail; @@ -835,7 +834,7 @@ public class Jackson2ObjectMapperBuilder { objectMapper.configure(mapperFeature, enabled); } else { - throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName()); + throw new IllegalArgumentException("Unknown feature class: " + feature.getClass().getName()); } } diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index 1f489ab00d0..9bd77dc0d47 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -81,12 +81,10 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import kotlin.ranges.IntRange; import org.junit.jupiter.api.Test; -import org.springframework.beans.FatalBeanException; import org.springframework.http.ProblemDetail; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** @@ -105,7 +103,7 @@ class Jackson2ObjectMapperBuilderTests { @Test void unknownFeature() { - assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() -> + assertThatIllegalArgumentException().isThrownBy(() -> Jackson2ObjectMapperBuilder.json().featuresToEnable(Boolean.TRUE).build()); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java index 92a89e8fe07..3add547c036 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -59,11 +59,10 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.junit.jupiter.api.Test; -import org.springframework.beans.FatalBeanException; import org.springframework.http.ProblemDetail; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; /** * Test cases for {@link Jackson2ObjectMapperFactoryBean}. @@ -86,8 +85,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { @Test public void unknownFeature() { this.factory.setFeaturesToEnable(Boolean.TRUE); - assertThatExceptionOfType(FatalBeanException.class).isThrownBy( - this.factory::afterPropertiesSet); + assertThatIllegalArgumentException().isThrownBy(this.factory::afterPropertiesSet); } @Test