Skip to content

Can't add a new key into hash during iteration #200

Closed
@kwent

Description

@kwent

Hitting this error...

2014-03-08T01:01:34.567573+00:00 app[worker2.2]: 2014-03-08T01:01:34Z 2 TID-orymt1k2g WARN: can't add a new key into hash during iteration
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: 2014-03-08T01:01:34Z 2 TID-orymt1k2g WARN: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:285:in `[]='
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:285:in `challenge'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:136:in `block (2 levels) in filter_response'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:133:in `each'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:133:in `block in filter_response'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:132:in `each'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient/auth.rb:132:in `filter_response'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:1100:in `block in do_get_block'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:1099:in `collect'
2014-03-08T01:01:34.567652+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:1099:in `do_get_block'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/httpclient.rb:34:in `block in do_get_block_with_newrelic'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/cross_app_tracing.rb:41:in `trace_http_request'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/httpclient.rb:33:in `do_get_block_with_newrelic'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:887:in `block in do_request'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:981:in `protect_keep_alive_disconnected'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:886:in `do_request'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:774:in `request'
2014-03-08T01:01:34.567911+00:00 app[worker2.2]: /app/vendor/bundle/ruby/2.0.0/gems/httpclient-2.3.4.1/lib/httpclient.rb:694:in `delete'

Activity

michaeldbarry

michaeldbarry commented on Mar 17, 2014

@michaeldbarry

I too get this error when accessing a basic auth http site numerous times
and for whatever reason the site requires reauth
jruby 1.7.9 (1.9.3p392) 2013-12-06 87b108a on OpenJDK 64-Bit Server VM 1.6.0_24-b24 [linux-amd64]

michaeldbarry

michaeldbarry commented on Mar 17, 2014

@michaeldbarry

So would the fix for this be changing

       @authenticator.each do |auth|

to

       @authenticator.dup.each do |auth|
kwent

kwent commented on Mar 18, 2014

@kwent
Author

Is this fix working ? Can we hope a pull request and a merge in master ?

nahi

nahi commented on May 21, 2014

@nahi
Owner

Sorry for late response. I want to fix this issue for the next release.

Is this like threading issue? @challengeable is the object that causes the exception and here's the only location iterating @challengeable: https://github.com/nahi/httpclient/blob/master/lib/httpclient/auth.rb#L274
By another thread, I'm guessing...

added a commit that references this issue on Jun 7, 2014
added 2 commits that reference this issue on Aug 10, 2014
2ea9496
6973110
added a commit that references this issue on Jan 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @nahi@michaeldbarry@kwent

      Issue actions

        Can't add a new key into hash during iteration · Issue #200 · nahi/httpclient