JinHyuk Kim created HBASE-30070:
-----------------------------------

             Summary: HBase shell fails with NoMethodError when loading scripts 
from LOAD_PATH after JRuby 9.4 upgrade
                 Key: HBASE-30070
                 URL: https://issues.apache.org/jira/browse/HBASE-30070
             Project: HBase
          Issue Type: Bug
          Components: shell
         Environment:  

 
            Reporter: JinHyuk Kim
            Assignee: JinHyuk Kim


h1. Background

After upgrading to JRuby 9.4, running hbase shell with a script that is 
resolved via {{$LOAD_PATH}} (rather than a direct filesystem path) fails with:  
                                                                                
                                                                         
{code:java}
ERROR NoMethodError: undefined method `findFileForLoad' for 
#<Java::OrgJrubyRuntimeLoad::LoadService:0x746da54f>   {code}
                                                                                
           
{{IRB::HBaseLoader.path_for_load}} in _hbase-shell/src/main/ruby/irb/hirb.rb_ 
calls {{{}LoadService#findFileForLoad{}}}, which returned a SearchState object. 
JRuby 9.4 removed the SearchState class and all methods that depended on it 
(including {{{}findFileForLoad{}}}) as part of a deprecated code cleanup:

[https://github.com/jruby/jruby/commit/78a4bea5d8634e60fff9f914ef302a635dc97ae6]

This affects any invocation where the script file is not found directly on disk 
and needs to be resolved through {{{}$LOAD_PATH{}}}, including scripts inside 
jars on the classpath.
h1. Steps to reproduce

1. Load a script from {{$LOAD_PATH}} (e.g. JRuby stdlib):
{code:java}
./bin/hbase shell abbrev.rb 
{code}
Expected: loads abbrev.rb from JRuby's stdlib jar. 
Actual: NoMethodError: undefined method 'findFileForLoad'

2. Load a non-existing script:
{code:java}
./bin/hbase shell -n does_not_exist.rb 
{code}
Expected: LoadError: no such file to load – does_not_exist.rb
Actual: NoMethodError: undefined method 'findFileForLoad'
h1. Fix

Replace the internal {{LoadService#findFileForLoad}} SearchState API with 
{*}{{$LOAD_PATH.resolve_feature_path}}{*}, which is the public Ruby API backed 
by the same underlying {{{}LibrarySearcher#findLibraryForRequire{}}}. Available 
in JRuby 9.4 and returns nil on miss.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to