summary refs log tree commit diff
diff options
context:
space:
mode:
authorPetr Vaněk <arkamar@atlas.cz>2022-05-19 16:23:59 +0200
committerGitHub <noreply@github.com>2022-05-19 14:23:59 +0000
commit684feeaf2f32d853b02951794789830e48e75a64 (patch)
treed20add5644031be0dd81bb18cbd483ba79928d72
parentAdd a unique index to `state_group_edges` to prevent duplicates being acciden... (diff)
downloadsynapse-684feeaf2f32d853b02951794789830e48e75a64.tar.xz
Properly close providers.json file stream. (#12794)
-rw-r--r--changelog.d/12794.bugfix1
-rw-r--r--synapse/config/oembed.py6
2 files changed, 4 insertions, 3 deletions
diff --git a/changelog.d/12794.bugfix b/changelog.d/12794.bugfix
new file mode 100644
index 0000000000..2d1a2838e1
--- /dev/null
+++ b/changelog.d/12794.bugfix
@@ -0,0 +1 @@
+Fix a bug introduced in 1.43.0 where a file (`providers.json`) was never closed. Contributed by @arkamar.
diff --git a/synapse/config/oembed.py b/synapse/config/oembed.py
index 690ffb5296..e9edea0731 100644
--- a/synapse/config/oembed.py
+++ b/synapse/config/oembed.py
@@ -57,9 +57,9 @@ class OembedConfig(Config):
         """
         # Whether to use the packaged providers.json file.
         if not oembed_config.get("disable_default_providers") or False:
-            providers = json.load(
-                pkg_resources.resource_stream("synapse", "res/providers.json")
-            )
+            with pkg_resources.resource_stream("synapse", "res/providers.json") as s:
+                providers = json.load(s)
+
             yield from self._parse_and_validate_provider(
                 providers, config_path=("oembed",)
             )