From 851f77f9da075be8d90cf71970371ce858f26646 Mon Sep 17 00:00:00 2001 From: Alex Vear Date: Tue, 17 Oct 2023 15:48:25 +0100 Subject: [PATCH] Disable automatic Jackson object->JSON features These were frequently resulting in logging failures from trying to use reflection to make things public and cyclical object references. The main areas this affected were Jetty servlet request objects and the built-in Java HTTP client. --- src/com/kroo/typeset/logback/JsonLayout.clj | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/kroo/typeset/logback/JsonLayout.clj b/src/com/kroo/typeset/logback/JsonLayout.clj index a821ba5..f272dbf 100644 --- a/src/com/kroo/typeset/logback/JsonLayout.clj +++ b/src/com/kroo/typeset/logback/JsonLayout.clj @@ -8,7 +8,7 @@ (java.util HashMap List Map Map$Entry) (org.slf4j Marker) (org.slf4j.event KeyValuePair) - (com.fasterxml.jackson.databind ObjectMapper SerializationFeature)) + (com.fasterxml.jackson.databind MapperFeature ObjectMapper SerializationFeature)) (:gen-class :extends ch.qos.logback.core.LayoutBase :main false @@ -46,7 +46,13 @@ (-> (j/object-mapper opts) (.disable SerializationFeature/FAIL_ON_EMPTY_BEANS) (.disable SerializationFeature/FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS) - (.enable SerializationFeature/WRITE_SELF_REFERENCES_AS_NULL))) + (.enable SerializationFeature/WRITE_SELF_REFERENCES_AS_NULL) + (.enable SerializationFeature/WRITE_ENUMS_USING_TO_STRING) + (.configure MapperFeature/CAN_OVERRIDE_ACCESS_MODIFIERS false) + (.configure MapperFeature/OVERRIDE_PUBLIC_ACCESS_MODIFIERS false) + (.configure MapperFeature/AUTO_DETECT_GETTERS false) + (.configure MapperFeature/AUTO_DETECT_SETTERS false) + (.configure MapperFeature/AUTO_DETECT_FIELDS false))) (defn -init "Method invoked during object initialisation. Sets the default value for the