From 9656006778789850892403107be0a85074959765 Mon Sep 17 00:00:00 2001 From: Istvan Toth Date: Tue, 13 Feb 2024 11:21:01 +0100 Subject: [PATCH] HBASE-28353 Close HBase connection on implicit exit from HBase shell (#5673) Signed-off-by: Bryan Beaudreault Signed-off-by: Balazs Meszaros --- hbase-shell/src/main/ruby/shell.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index 39fbd2ccba16..46b38dd96b89 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -108,11 +108,6 @@ class Shell # exit the interactive shell and save that this # happend via a call to exit def exit(ret = 0) - # Non-deamon Netty threadpool in ZK ClientCnxnSocketNetty cannot be shut down otherwise - begin - hbase.shutdown - rescue Exception - end @exit_code = ret IRB.irb_exit(IRB.CurrentContext.irb, ret) end @@ -323,6 +318,13 @@ def get_workspace hbase_receiver.send :define_singleton_method, :exit, lambda { |rc = 0| @shell.exit(rc) } + at_exit do + # Non-deamon Netty threadpool in ZK ClientCnxnSocketNetty cannot be shut down otherwise + begin + hbase.shutdown + rescue Exception + end + end ::IRB::WorkSpace.new(hbase_receiver.get_binding) end