Details
-
Bug
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
Description
If an HippoEvent to be logged by the AuditLogger contains an Exception with a nested Exception, the serialization to JSON format fails with:
com.google.common.eventbus.EventBus$LoggingSubscriberExceptionHandler handleException
SEVERE: Could not dispatch event: org.hippoecm.repository.audit.AuditLogger@2f82832f to public void org.hippoecm.repository.audit.AuditLogger.logHippoEvent(org.onehippo.cms7.event.HippoEvent) throws java.lang.reflect.InvocationTargetException
net.sf.json.JSONException: There is a cycle in the hierarchy!
at net.sf.json.util.CycleDetectionStrategy$StrictCycleDetectionStrategy.handleRepeatedReferenceAsObject(CycleDetectionStrategy.java:97)
at net.sf.json.JSONObject._fromBean(JSONObject.java:857)
at net.sf.json.JSONObject.fromObject(JSONObject.java:192)
at net.sf.json.JSONObject._processValue(JSONObject.java:2774)
at net.sf.json.JSONObject._setInternal(JSONObject.java:2798)
at net.sf.json.JSONObject.setValue(JSONObject.java:1507)
at net.sf.json.JSONObject._fromBean(JSONObject.java:940)
at net.sf.json.JSONObject.fromObject(JSONObject.java:192)
...
at net.sf.json.JSONObject.fromObject(JSONObject.java:192)
at net.sf.json.JSONObject._processValue(JSONObject.java:2774)
at net.sf.json.JSONObject.processValue(JSONObject.java:2833)
at net.sf.json.JSONObject.element(JSONObject.java:1871)
at net.sf.json.JSONObject.putAll(JSONObject.java:2489)
at net.sf.json.JSONObject.putAll(JSONObject.java:2471)
at org.hippoecm.repository.audit.AuditLogger.logHippoEvent(AuditLogger.java:38)
There might be (are) ways to force the JSONObject to be more lenient and make it possible to serialize such nested Exceptions.
However the real question should be: do we actually need/want full serialization of Exceptions in the audit log (meaning: a full stacktrace String dump).
IMO the audit log is not intended for this type of data: it should log that an exception occurred, and at least the Exception message.
But for the full stacktrace dump the exception should (and is!) logged in a different log file, and can/must be looked up there if needed.
My proposal to fix this is therefore to override the serialization of an Exception object in the HippoEvent values to output the Exception.getMessage() instead.
Note: this behavior is also present in 7.9 and 7.8, so we might need to backport this as well.
Attachments
Issue Links
- is backported by
-
REPO-1238 [7.9 backport] AuditLogger fails to JSON serialize nested exceptions
- Closed