Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hystrix-clj IllegalStateException when using collapsers #132

Closed
dinedal opened this issue Mar 27, 2013 · 3 comments · Fixed by #135
Closed

Hystrix-clj IllegalStateException when using collapsers #132

dinedal opened this issue Mar 27, 2013 · 3 comments · Fixed by #135

Comments

@dinedal
Copy link
Contributor

dinedal commented Mar 27, 2013

Using a very simple example:

(defcommand foo [a] (+ 1 a))
(defcollapser fooz (collapse [arg-lists] (instantiate foo (map first arg-lists))) (map [arg-lists batch-result] batch-result))

Calling (fooz [1]) raises:

java.lang.RuntimeException: HystrixCollapser$0 HystrixCollapser failed while executing.
    at com.netflix.hystrix.HystrixCollapser.execute(HystrixCollapser.java:302)
    at com.netflix.hystrix.core.proxy$com.netflix.hystrix.HystrixCollapser$0.execute(Unknown Source)
    at com.netflix.hystrix.core$execute.doInvoke(core.clj:465)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:619)
...
Caused by: java.lang.IllegalStateException: HystrixRequestContext.initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.
    at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableDefault.get(HystrixRequestVariableDefault.java:79)
    at com.netflix.hystrix.strategy.concurrency.HystrixRequestVariableHolder.get(HystrixRequestVariableHolder.java:68)
    at com.netflix.hystrix.HystrixCollapser.getCollapserForUserRequest(HystrixCollapser.java:392)
    at com.netflix.hystrix.HystrixCollapser.queue(HystrixCollapser.java:321)
    at com.netflix.hystrix.core.proxy$com.netflix.hystrix.HystrixCollapser$0.queue(Unknown Source)
    at com.netflix.hystrix.HystrixCollapser.execute(HystrixCollapser.java:290)
    ... 30 more
@benjchristensen
Copy link
Contributor

Yes, as per the error message Collapsers are one of the things that needs a HystrixRequestContext to work.

HystrixRequestContext.initializeContext() must be called at the beginning of each request before RequestVariable functionality can be used.

You can find documentation on the subject here: https://github.com/Netflix/Hystrix/wiki/How-To-Use#wiki-RequestContextSetup

@dinedal
Copy link
Contributor Author

dinedal commented Mar 28, 2013

Ah, in that case, I'll try my hand at adding that in

@daveray
Copy link
Contributor

daveray commented Mar 28, 2013

Also see the request context test fixture in the hystrix-clj tests for an example: https://github.com/Netflix/Hystrix/blob/master/hystrix-contrib/hystrix-clj/src/test/clojure/com/netflix/hystrix/core_test.clj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants