Skip to content

Commit 851f77f

Browse files
committed
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.
1 parent 4b889a7 commit 851f77f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/com/kroo/typeset/logback/JsonLayout.clj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
(java.util HashMap List Map Map$Entry)
99
(org.slf4j Marker)
1010
(org.slf4j.event KeyValuePair)
11-
(com.fasterxml.jackson.databind ObjectMapper SerializationFeature))
11+
(com.fasterxml.jackson.databind MapperFeature ObjectMapper SerializationFeature))
1212
(:gen-class
1313
:extends ch.qos.logback.core.LayoutBase
1414
:main false
@@ -46,7 +46,13 @@
4646
(-> (j/object-mapper opts)
4747
(.disable SerializationFeature/FAIL_ON_EMPTY_BEANS)
4848
(.disable SerializationFeature/FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS)
49-
(.enable SerializationFeature/WRITE_SELF_REFERENCES_AS_NULL)))
49+
(.enable SerializationFeature/WRITE_SELF_REFERENCES_AS_NULL)
50+
(.enable SerializationFeature/WRITE_ENUMS_USING_TO_STRING)
51+
(.configure MapperFeature/CAN_OVERRIDE_ACCESS_MODIFIERS false)
52+
(.configure MapperFeature/OVERRIDE_PUBLIC_ACCESS_MODIFIERS false)
53+
(.configure MapperFeature/AUTO_DETECT_GETTERS false)
54+
(.configure MapperFeature/AUTO_DETECT_SETTERS false)
55+
(.configure MapperFeature/AUTO_DETECT_FIELDS false)))
5056

5157
(defn -init
5258
"Method invoked during object initialisation. Sets the default value for the

0 commit comments

Comments
 (0)