|
29 | 29 | import com.fasterxml.jackson.annotation.JsonCreator.Mode;
|
30 | 30 | import com.fasterxml.jackson.annotation.JsonFormat;
|
31 | 31 | import com.fasterxml.jackson.annotation.JsonInclude;
|
| 32 | +import com.fasterxml.jackson.core.JsonFactory; |
32 | 33 | import com.fasterxml.jackson.core.JsonGenerator;
|
33 | 34 | import com.fasterxml.jackson.core.JsonParser;
|
34 | 35 | import com.fasterxml.jackson.core.ObjectCodec;
|
| 36 | +import com.fasterxml.jackson.core.util.JsonRecyclerPools.LockFreePool; |
| 37 | +import com.fasterxml.jackson.core.util.JsonRecyclerPools.ThreadLocalPool; |
35 | 38 | import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
36 | 39 | import com.fasterxml.jackson.databind.DeserializationConfig;
|
37 | 40 | import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
53 | 56 | import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
|
54 | 57 | import org.assertj.core.api.InstanceOfAssertFactories;
|
55 | 58 | import org.junit.jupiter.api.Test;
|
| 59 | +import org.junit.jupiter.api.condition.EnabledOnJre; |
| 60 | +import org.junit.jupiter.api.condition.JRE; |
56 | 61 |
|
57 | 62 | import org.springframework.aot.hint.RuntimeHints;
|
58 | 63 | import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
|
@@ -491,6 +496,27 @@ void shouldRegisterPropertyNamingStrategyHints() {
|
491 | 496 | "UPPER_CAMEL_CASE", "SNAKE_CASE", "UPPER_SNAKE_CASE", "LOWER_CASE", "KEBAB_CASE", "LOWER_DOT_CASE");
|
492 | 497 | }
|
493 | 498 |
|
| 499 | + @Test |
| 500 | + void shouldUseThreadLocalPool() { |
| 501 | + this.contextRunner.withPropertyValues("spring.threads.virtual.enabled:false").run((context) -> { |
| 502 | + ObjectMapper mapper = context.getBean(ObjectMapper.class); |
| 503 | + assertThat(mapper).extracting(ObjectMapper::getFactory) |
| 504 | + .extracting(JsonFactory::_getRecyclerPool) |
| 505 | + .isInstanceOf(ThreadLocalPool.class); |
| 506 | + }); |
| 507 | + } |
| 508 | + |
| 509 | + @Test |
| 510 | + @EnabledOnJre(JRE.JAVA_21) |
| 511 | + void shouldUseVirtualThread() { |
| 512 | + this.contextRunner.withPropertyValues("spring.threads.virtual.enabled:true").run((context) -> { |
| 513 | + ObjectMapper mapper = context.getBean(ObjectMapper.class); |
| 514 | + assertThat(mapper).extracting(ObjectMapper::getFactory) |
| 515 | + .extracting(JsonFactory::_getRecyclerPool) |
| 516 | + .isInstanceOf(LockFreePool.class); |
| 517 | + }); |
| 518 | + } |
| 519 | + |
494 | 520 | private void shouldRegisterPropertyNamingStrategyHints(Class<?> type, String... fieldNames) {
|
495 | 521 | RuntimeHints hints = new RuntimeHints();
|
496 | 522 | new JacksonAutoConfigurationRuntimeHints().registerHints(hints, getClass().getClassLoader());
|
|
0 commit comments