Refine Jackson2ObjectMapperBuilder#configureFeature exception handling

This commit changes the FatalBeanException previously thrown for
an IllegalArgumentException which seems more suitable for that
use case.

Closes gh-29860
This commit is contained in:
Sébastien Deleuze
2023-01-20 10:07:05 +01:00
parent 33f1c9b614
commit 4a4b332709
3 changed files with 7 additions and 13 deletions

View File

@@ -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.lang.Nullable;
@@ -837,7 +836,7 @@ public class Jackson2ObjectMapperBuilder {
objectMapper.configure((MapperFeature) feature, enabled);
}
else {
throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
throw new IllegalArgumentException("Unknown feature class: " + feature.getClass().getName());
}
}