From 684feeaf2f32d853b02951794789830e48e75a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Thu, 19 May 2022 16:23:59 +0200 Subject: [PATCH] Properly close providers.json file stream. (#12794) --- changelog.d/12794.bugfix | 1 + synapse/config/oembed.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelog.d/12794.bugfix diff --git a/changelog.d/12794.bugfix b/changelog.d/12794.bugfix new file mode 100644 index 000000000000..2d1a2838e128 --- /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 690ffb52963e..e9edea073123 100644 --- a/synapse/config/oembed.py +++ b/synapse/config/oembed.py @@ -57,9 +57,9 @@ def _parse_and_validate_providers( """ # 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",) )