From cfea3773dbda049a87723cbc2a7ac98f85bf1265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Ka=C5=BAmierczyk?= Date: Wed, 30 Oct 2024 15:57:45 +0100 Subject: [PATCH] Ref #10 use try/finally for reading in get_javacore_set_in_xml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Krzysztof Kaźmierczyk --- javacore_set.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/javacore_set.py b/javacore_set.py index c5eff1d..2f40fb3 100644 --- a/javacore_set.py +++ b/javacore_set.py @@ -447,10 +447,12 @@ def get_javacore_set_in_xml(self): Returns: str: The JavaCore set in the XML format. """ - file = open(self.report_xml_file, "r") - content = file.read() - file.close() - return content + try: + file = open(self.report_xml_file, "r") + content = file.read() + return content + finally: + file.close() @staticmethod def __create_index_html(input_dir, output_dir):