arvindKandpal-ksolves opened a new pull request, #7931:
URL: https://github.com/apache/hbase/pull/7931

   ### Why are the changes needed?
   As reported in HBASE-28660, when a user enters an incorrect command like 
`list_namespace, 'ns.*'`, the JRuby parser mistakenly creates a local variable 
named `list_namespace` initialized to `nil` before throwing a SyntaxError. 
Because Ruby prioritizes local variables over method calls, subsequent valid 
`list_namespace` commands return empty/nil instead of executing the actual 
shell command.
   
   ### How does this PR fix the problem?
   - Added a cleanup mechanism inside `hirb.rb`'s `eval_input` loop.
   - After evaluating a line, it checks if any newly created local variables 
match the names of registered HBase shell commands.
   - If a collision (shadowing) is detected, it outputs a warning message to 
the user (`WARN: '<command>' is a reserved HBase command. Local variable 
assignment ignored.`).
   - It then safely discards the polluted binding, creates a fresh workspace 
binding, and restores only the non-conflicting user variables.
   - Added comprehensive test cases in `general_test_cluster.rb` to cover 
direct assignments, syntax errors, and safe variable preservations.
   
   ### Tests run
   Ran the shell tests locally and verified that the behavior works as expected 
without regressions.
   `mvn test -Dtest=TestShell -pl hbase-shell` (All tests passed).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to