Skip to content

Commit

Permalink
Disable automatic Jackson object->JSON features
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
axvr committed Oct 17, 2023
1 parent 4b889a7 commit 851f77f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/com/kroo/typeset/logback/JsonLayout.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 851f77f

Please sign in to comment.