From c644dd67075fe0d0a99f6e2f551c78720400bdc2 Mon Sep 17 00:00:00 2001 From: JayT106 Date: Tue, 19 Oct 2021 04:55:55 -0400 Subject: [PATCH] fix: handle file close logic (#679) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * handle file close logic * Update rpc/ethereum/namespaces/debug/utils.go * update changelog Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> --- CHANGELOG.md | 4 ++++ rpc/ethereum/namespaces/debug/utils.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bd99dcb..df2cb276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [tharsis#660](https://github.com/tharsis/ethermint/pull/660) Fix `nil` pointer panic in `ApplyNativeMessage`. * (evm, test) [tharsis#649](https://github.com/tharsis/ethermint/pull/649) Test DynamicFeeTx. +### Improvements + +(rpc) [tharsis#679](https://github.com/tharsis/ethermint/pull/679) Fix file close handle. + ## [v0.7.0] - 2021-10-07 ### API Breaking diff --git a/rpc/ethereum/namespaces/debug/utils.go b/rpc/ethereum/namespaces/debug/utils.go index 0910040a..b8a2a40f 100644 --- a/rpc/ethereum/namespaces/debug/utils.go +++ b/rpc/ethereum/namespaces/debug/utils.go @@ -48,7 +48,11 @@ func writeProfile(name, file string, log log.Logger) error { if err != nil { return err } - defer f.Close() - return p.WriteTo(f, 0) + if err := p.WriteTo(f, 0); err != nil { + f.Close() + return err + } + + return f.Close() }