Skip to content

Commit 63b4e68

Browse files
re-thcrbygrave
andauthored
Faster jackson defaults (#289)
* 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>
1 parent 0a0ad75 commit 63b4e68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

jsonb-jackson/src/main/java/io/avaje/jsonb/jackson/JacksonAdapter.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.avaje.jsonb.jackson;
22

33
import com.fasterxml.jackson.core.JsonFactory;
4+
import com.fasterxml.jackson.core.StreamReadFeature;
45
import com.fasterxml.jackson.core.io.SegmentedStringWriter;
56
import com.fasterxml.jackson.core.util.ByteArrayBuilder;
67
import io.avaje.jsonb.JsonIoException;
@@ -101,7 +102,10 @@ public Builder failOnUnknown(boolean failOnUnknown) {
101102
*/
102103
public JacksonAdapter build() {
103104
if (jsonFactory == null) {
104-
jsonFactory = new JsonFactory();
105+
jsonFactory = JsonFactory.builder()
106+
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
107+
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
108+
.build();
105109
}
106110
return new JacksonAdapter(serializeNulls, serializeEmpty, failOnUnknown, jsonFactory);
107111
}
@@ -118,7 +122,6 @@ public JacksonAdapter build() {
118122
public JacksonAdapter() {
119123
this(false, false, false, new JsonFactory());
120124
}
121-
122125

123126
public JacksonAdapter(JsonFactory factory) {
124127
this(false, false, false, factory);

0 commit comments

Comments
 (0)