vrivellino / chef-java_se

Chef cookbook to install and configure Oracle's Java SE JDK http://www.oracle.com/technetwork/java/javase/downloads/index.html
MIT License
3 stars 5 forks source link

Infinite recursive calls in downloader class (v9.0.4) #3

Open Annih opened 6 years ago

Annih commented 6 years ago

Hello,

With the latest version of java_se (9.0.4) our code relying on it is not working anymore, hitting a stack too deep error:

SystemStackError:    stack level too deep
     # /tmp/d20180411-7446-1f6rgce/cookbooks/java_se/libraries/downloader.rb:78:in `first_hash_argument'
     # /tmp/d20180411-7446-1f6rgce/cookbooks/java_se/libraries/downloader.rb:73:in `allow_redirections'
     # /tmp/d20180411-7446-1f6rgce/cookbooks/java_se/libraries/downloader.rb:60:in `open_uri'
dhoer commented 6 years ago

I don't see the 9 branch. But if I had to guess, the path might of changed, e.g., 9.0.4+11? http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz

dhoer commented 6 years ago

I forgot master was 9 and not 10. The link still looks good https://github.com/vrivellino/chef-java_se/blob/master/libraries/default.rb#L30-L31

Annih commented 6 years ago

Hello,

I have more context :)

  1. I miss read my Berksfile, the error occurred with version 8.162.0, but is still present in higher version :(
  2. The error does not occure while trying to download java, but in Chefspec when trying to download an out-of-date fauxhai version:
    
     # /tmp/d20180412-7298-1twzlcr/cookbooks/java_se/libraries/downloader.rb:66:in `open_uri'
     # ./vendor/bundle/ruby/2.3.0/gems/fauxhai-6.1.0/lib/fauxhai/mocker.rb:58:in `block in fauxhai_data'
     # ./vendor/bundle/ruby/2.3.0/gems/fauxhai-6.1.0/lib/fauxhai/mocker.rb:80:in `fauxhai_data'
     # ./vendor/bundle/ruby/2.3.0/gems/fauxhai-6.1.0/lib/fauxhai/mocker.rb:31:in `initialize'
     # ./vendor/bundle/ruby/2.3.0/gems/fauxhai-6.1.0/lib/fauxhai.rb:12:in `new'
     # ./vendor/bundle/ruby/2.3.0/gems/fauxhai-6.1.0/lib/fauxhai.rb:12:in `mock'
     # ./vendor/bundle/ruby/2.3.0/gems/chefspec-7.2.0/lib/chefspec/solo_runner.rb:375:in `client'
     # ./vendor/bundle/ruby/2.3.0/gems/chefspec-7.2.0/lib/chefspec/solo_runner.rb:143:in `node'
     # ./vendor/bundle/ruby/2.3.0/gems/chefspec-7.2.0/lib/chefspec/solo_runner.rb:108:in `converge'
     # ./spec/unit/resources/user_spec.rb:7:in `block (3 levels) in <top (required)>'
     # ./spec/unit/resources/user_spec.rb:80:in `block (3 levels) in <top (required)>'```

I think this is due to the way you patch open_uri, if the code is applied multiple times, it'll end up call "original_uri" which is the patched version calling again original_uri, etc.

I hope this happens only in tests, but we never know. I'll send a PR soon to properly patch this method.