mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Merge branch '3.5.x' into 4.0.x
Closes gh-49798
This commit is contained in:
+5
-7
@@ -498,13 +498,11 @@ public final class JacksonAutoConfiguration {
|
||||
|
||||
private void configureConstructorDetector(MapperBuilder<?, ?> builder) {
|
||||
ConstructorDetectorStrategy strategy = this.jacksonProperties.getConstructorDetector();
|
||||
if (strategy != null) {
|
||||
switch (strategy) {
|
||||
case USE_PROPERTIES_BASED -> builder.constructorDetector(ConstructorDetector.USE_PROPERTIES_BASED);
|
||||
case USE_DELEGATING -> builder.constructorDetector(ConstructorDetector.USE_DELEGATING);
|
||||
case EXPLICIT_ONLY -> builder.constructorDetector(ConstructorDetector.EXPLICIT_ONLY);
|
||||
default -> builder.constructorDetector(ConstructorDetector.DEFAULT);
|
||||
}
|
||||
switch (strategy) {
|
||||
case USE_PROPERTIES_BASED -> builder.constructorDetector(ConstructorDetector.USE_PROPERTIES_BASED);
|
||||
case USE_DELEGATING -> builder.constructorDetector(ConstructorDetector.USE_DELEGATING);
|
||||
case EXPLICIT_ONLY -> builder.constructorDetector(ConstructorDetector.EXPLICIT_ONLY);
|
||||
default -> builder.constructorDetector(ConstructorDetector.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -96,7 +96,7 @@ public class JacksonProperties {
|
||||
* Strategy to use to auto-detect constructor, and in particular behavior with
|
||||
* single-argument constructors.
|
||||
*/
|
||||
private @Nullable ConstructorDetectorStrategy constructorDetector;
|
||||
private ConstructorDetectorStrategy constructorDetector = ConstructorDetectorStrategy.DEFAULT;
|
||||
|
||||
/**
|
||||
* Time zone used when formatting dates. For instance, "America/Los_Angeles" or
|
||||
@@ -173,11 +173,11 @@ public class JacksonProperties {
|
||||
this.defaultLeniency = defaultLeniency;
|
||||
}
|
||||
|
||||
public @Nullable ConstructorDetectorStrategy getConstructorDetector() {
|
||||
public ConstructorDetectorStrategy getConstructorDetector() {
|
||||
return this.constructorDetector;
|
||||
}
|
||||
|
||||
public void setConstructorDetector(@Nullable ConstructorDetectorStrategy constructorDetector) {
|
||||
public void setConstructorDetector(ConstructorDetectorStrategy constructorDetector) {
|
||||
this.constructorDetector = constructorDetector;
|
||||
}
|
||||
|
||||
|
||||
+9
-13
@@ -340,19 +340,15 @@ public final class Jackson2AutoConfiguration {
|
||||
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder builder) {
|
||||
org.springframework.boot.jackson2.autoconfigure.Jackson2Properties.ConstructorDetectorStrategy strategy = this.jacksonProperties
|
||||
.getConstructorDetector();
|
||||
if (strategy != null) {
|
||||
builder.postConfigurer((objectMapper) -> {
|
||||
switch (strategy) {
|
||||
case USE_PROPERTIES_BASED ->
|
||||
objectMapper.setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED);
|
||||
case USE_DELEGATING ->
|
||||
objectMapper.setConstructorDetector(ConstructorDetector.USE_DELEGATING);
|
||||
case EXPLICIT_ONLY ->
|
||||
objectMapper.setConstructorDetector(ConstructorDetector.EXPLICIT_ONLY);
|
||||
default -> objectMapper.setConstructorDetector(ConstructorDetector.DEFAULT);
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.postConfigurer((objectMapper) -> {
|
||||
switch (strategy) {
|
||||
case USE_PROPERTIES_BASED ->
|
||||
objectMapper.setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED);
|
||||
case USE_DELEGATING -> objectMapper.setConstructorDetector(ConstructorDetector.USE_DELEGATING);
|
||||
case EXPLICIT_ONLY -> objectMapper.setConstructorDetector(ConstructorDetector.EXPLICIT_ONLY);
|
||||
default -> objectMapper.setConstructorDetector(ConstructorDetector.DEFAULT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -108,7 +108,7 @@ public class Jackson2Properties {
|
||||
* Strategy to use to auto-detect constructor, and in particular behavior with
|
||||
* single-argument constructors.
|
||||
*/
|
||||
private @Nullable ConstructorDetectorStrategy constructorDetector;
|
||||
private ConstructorDetectorStrategy constructorDetector = ConstructorDetectorStrategy.DEFAULT;
|
||||
|
||||
/**
|
||||
* Time zone used when formatting dates. For instance, "America/Los_Angeles" or
|
||||
@@ -190,11 +190,11 @@ public class Jackson2Properties {
|
||||
}
|
||||
|
||||
@DeprecatedConfigurationProperty(reason = "Deprecated in favor of Jackson 3", since = "4.0.0")
|
||||
public @Nullable ConstructorDetectorStrategy getConstructorDetector() {
|
||||
public ConstructorDetectorStrategy getConstructorDetector() {
|
||||
return this.constructorDetector;
|
||||
}
|
||||
|
||||
public void setConstructorDetector(@Nullable ConstructorDetectorStrategy constructorDetector) {
|
||||
public void setConstructorDetector(ConstructorDetectorStrategy constructorDetector) {
|
||||
this.constructorDetector = constructorDetector;
|
||||
}
|
||||
|
||||
|
||||
-4
@@ -1,9 +1,5 @@
|
||||
{
|
||||
"properties": [
|
||||
{
|
||||
"name": "spring.jackson2.constructor-detector",
|
||||
"defaultValue": "default"
|
||||
},
|
||||
{
|
||||
"name": "spring.jackson2.datatype.enum",
|
||||
"description": "Jackson on/off features for enums."
|
||||
|
||||
Reference in New Issue
Block a user