Skip to content

Commit

Permalink
Fix block not being called by RubyCoreSupport.open_file on JRuby 9.2.
Browse files Browse the repository at this point in the history
Using a refinement would cause the block parameter to be ignored.

https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
jruby/jruby#6009

Use `send(:using, Module)` instead of `using Module` as a workaround.
  • Loading branch information
philr committed Dec 23, 2019
1 parent 37bf107 commit 4e01d06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/tzinfo/zoneinfo_data_source.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module TZInfo
using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
# Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
# refinement causes calls to RubyCoreSupport.file_open to fail to pass the
# block parameter.
#
# https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
# https://github.com/jruby/jruby/issues/6009
send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)

# An InvalidZoneinfoDirectory exception is raised if the DataSource is
# set to a specific zoneinfo path, which is not a valid zoneinfo directory
Expand Down
10 changes: 8 additions & 2 deletions test/tc_zoneinfo_data_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@

include TZInfo

using RubyCoreSupport::UntaintExt if RubyCoreSupport.const_defined?(:UntaintExt)
using TaintExt if Module.const_defined?(:TaintExt)
# Use send as a workaround for an issue on JRuby 9.2.9.0 where using the
# refinement causes calls to RubyCoreSupport.file_open to fail to pass the block
# parameter.
#
# https://travis-ci.org/tzinfo/tzinfo/jobs/628812051#L1931
# https://github.com/jruby/jruby/issues/6009
send(:using, TZInfo::RubyCoreSupport::UntaintExt) if TZInfo::RubyCoreSupport.const_defined?(:UntaintExt)
send(:using, TaintExt) if Module.const_defined?(:TaintExt)

class TCZoneinfoDataSource < Minitest::Test
ZONEINFO_DIR = File.join(File.expand_path(File.dirname(__FILE__)), 'zoneinfo').untaint
Expand Down

0 comments on commit 4e01d06

Please sign in to comment.