Skip to content

Commit

Permalink
Faster Jackson default settings (helidon-io#9335)
Browse files Browse the repository at this point in the history
* Faster Jackson default settings
By default Jackson does not enable faster features to ensure 100% backwards compatibility. They should be safe and are already in use by many projects.

Note that USE_FAST_DOUBLE_WRITER has been ported to Java 20 and so has been left out.

* fix ci issues
  • Loading branch information
re-thc authored Oct 18, 2024
1 parent 6a93b66 commit 90eb0a2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,9 @@
import io.helidon.http.media.EntityWriter;
import io.helidon.http.media.MediaSupport;

import com.fasterxml.jackson.core.StreamReadFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
Expand Down Expand Up @@ -75,7 +77,10 @@ public static MediaSupport create(Config config, String name) {
Objects.requireNonNull(config);
Objects.requireNonNull(name);

ObjectMapper objectMapper = new ObjectMapper()
ObjectMapper objectMapper = JsonMapper.builder()
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
.build()
.registerModule(new ParameterNamesModule())
.registerModule(new Jdk8Module())
.registerModule(new JavaTimeModule());
Expand Down

0 comments on commit 90eb0a2

Please sign in to comment.