Skip to content

Commit

Permalink
Faster jackson defaults (#289)
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. Maybe something for the avaje native json to consider if not already (use built-in instead of custom)?

* Revert "Faster Jackson default settings"

This reverts commit 26125dc.

* 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. Maybe something for the avaje native json to consider if not already (use built-in instead of custom)?

* Format only change

* Remove extra whitespace only

---------

Co-authored-by: Rob Bygrave <robin.bygrave@gmail.com>
  • Loading branch information
re-thc and rbygrave authored Oct 8, 2024
1 parent 0a0ad75 commit 63b4e68
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.avaje.jsonb.jackson;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.StreamReadFeature;
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
import io.avaje.jsonb.JsonIoException;
Expand Down Expand Up @@ -101,7 +102,10 @@ public Builder failOnUnknown(boolean failOnUnknown) {
*/
public JacksonAdapter build() {
if (jsonFactory == null) {
jsonFactory = new JsonFactory();
jsonFactory = JsonFactory.builder()
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
.build();
}
return new JacksonAdapter(serializeNulls, serializeEmpty, failOnUnknown, jsonFactory);
}
Expand All @@ -118,7 +122,6 @@ public JacksonAdapter build() {
public JacksonAdapter() {
this(false, false, false, new JsonFactory());
}


public JacksonAdapter(JsonFactory factory) {
this(false, false, false, factory);
Expand Down

0 comments on commit 63b4e68

Please sign in to comment.