File tree Expand file tree Collapse file tree 4 files changed +24
-6
lines changed
deployment/src/main/java/io/quarkiverse/loggingjson/deployment
main/java/io/quarkiverse/loggingjson
test/java/io/quarkiverse/loggingjson/providers Expand file tree Collapse file tree 4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -34,19 +34,21 @@ FeatureBuildItem feature() {
3434 @ Record (ExecutionTime .RUNTIME_INIT )
3535 LogConsoleFormatBuildItem setUpConsoleFormatter (Capabilities capabilities , LoggingJsonRecorder recorder ,
3636 Config config ) {
37- return new LogConsoleFormatBuildItem (recorder .initializeConsoleJsonLogging (config , jsonFactory (capabilities )));
37+ return new LogConsoleFormatBuildItem (
38+ recorder .initializeConsoleJsonLogging (config , jsonFactory (capabilities , config .enabledJavaTimeModule )));
3839 }
3940
4041 @ BuildStep
4142 @ Record (ExecutionTime .RUNTIME_INIT )
4243 LogFileFormatBuildItem setUpFileFormatter (Capabilities capabilities , LoggingJsonRecorder recorder ,
4344 Config config ) {
44- return new LogFileFormatBuildItem (recorder .initializeFileJsonLogging (config , jsonFactory (capabilities )));
45+ return new LogFileFormatBuildItem (
46+ recorder .initializeFileJsonLogging (config , jsonFactory (capabilities , config .enabledJavaTimeModule )));
4547 }
4648
47- private JsonFactory jsonFactory (Capabilities capabilities ) {
49+ private JsonFactory jsonFactory (Capabilities capabilities , boolean enabledJavaTimeModule ) {
4850 if (capabilities .isPresent (Capability .JACKSON )) {
49- return new JacksonJsonFactory ();
51+ return new JacksonJsonFactory (enabledJavaTimeModule );
5052 } else if (capabilities .isPresent (Capability .JSONB )) {
5153 return new JsonbJsonFactory ();
5254 } else {
Original file line number Diff line number Diff line change @@ -31,6 +31,13 @@ public class Config {
3131 */
3232 @ ConfigItem
3333 public boolean prettyPrint ;
34+
35+ /**
36+ * Enable the JavaTimeModule for Jackson.
37+ */
38+ @ ConfigItem (defaultValue = "false" )
39+ public boolean enabledJavaTimeModule ;
40+
3441 /**
3542 * The special end-of-record delimiter to be used. By default, newline delimiter is used.
3643 */
Original file line number Diff line number Diff line change 55
66import com .fasterxml .jackson .databind .ObjectMapper ;
77import com .fasterxml .jackson .databind .SerializationFeature ;
8+ import com .fasterxml .jackson .datatype .jsr310 .JavaTimeModule ;
89
910import io .quarkiverse .loggingjson .JsonFactory ;
1011import io .quarkiverse .loggingjson .JsonGenerator ;
@@ -14,7 +15,11 @@ public class JacksonJsonFactory implements JsonFactory {
1415
1516 private final com .fasterxml .jackson .core .JsonFactory jsonFactory ;
1617
17- public JacksonJsonFactory () {
18+ public final boolean enabledJavaTimeModule ;
19+
20+ public JacksonJsonFactory (boolean enabledJavaTimeModule ) {
21+ this .enabledJavaTimeModule = enabledJavaTimeModule ;
22+
1823 jsonFactory = createJsonFactory ();
1924 }
2025
@@ -25,6 +30,10 @@ private com.fasterxml.jackson.core.JsonFactory createJsonFactory() {
2530 */
2631 .disable (SerializationFeature .FAIL_ON_EMPTY_BEANS );
2732
33+ if (this .enabledJavaTimeModule ) {
34+ objectMapper .registerModule (new JavaTimeModule ());
35+ }
36+
2837 try {
2938 objectMapper .findAndRegisterModules ();
3039 } catch (ServiceConfigurationError serviceConfigurationError ) {
Original file line number Diff line number Diff line change 1717abstract class JsonProviderBaseTest {
1818
1919 private static final JsonFactory jsonb = new JsonbJsonFactory ();
20- private static final JsonFactory jackson = new JacksonJsonFactory ();
20+ private static final JsonFactory jackson = new JacksonJsonFactory (false );
2121 private static final ObjectMapper mapper = new ObjectMapper ();
2222
2323 protected abstract Type type ();
You can’t perform that action at this time.
0 commit comments