summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-08-20 18:20:07 +0100
committerRichard van der Hoff <richard@matrix.org>2018-08-20 18:20:07 +0100
commit55e6bdf28798153de5c2a6cf9bf0a6618f59168a (patch)
tree21e7b2f9303aff50db85f7e5beec7a5dc61842f1
parentchangelog (diff)
downloadsynapse-55e6bdf28798153de5c2a6cf9bf0a6618f59168a.tar.xz
Robustness fix for logcontext filter
Make the logcontext filter not explode if it somehow ends up with a logcontext
of None, since that infinite-loops the whole logging system.
-rw-r--r--synapse/util/logcontext.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py
index 07e83fadda..848765e530 100644
--- a/synapse/util/logcontext.py
+++ b/synapse/util/logcontext.py
@@ -385,7 +385,13 @@ class LoggingContextFilter(logging.Filter):
         context = LoggingContext.current_context()
         for key, value in self.defaults.items():
             setattr(record, key, value)
-        context.copy_to(record)
+
+        # context should never be None, but if it somehow ends up being, then
+        # we end up in a death spiral of infinite loops, so let's check, for
+        # robustness' sake.
+        if context is not None:
+            context.copy_to(record)
+
         return True