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

Connection leaks in Zuul "post" filters #1196

Closed
wants to merge 1 commit into from

Conversation

denyska
Copy link

@denyska denyska commented Jul 20, 2016

Poor written "post" Zuul filter might cause response input stream not being closed and connection leaks in respective http-client connection pools.

@denyska denyska changed the title Bug/non closed stream Connection leaks in Zuul "post" filters Jul 20, 2016
@denyska
Copy link
Author

denyska commented Jul 21, 2016

@dsyer @spencergibb I wonder if I should move fix to eitherZuulServlet#service(), either com.netflix.zuul.context.RequestContext#unset(). Ideally streams should be closed on the same layer they are opened, however in Route-Post filter chains it is hard to achieve.

@dsyer
Copy link
Contributor

dsyer commented Jul 21, 2016

I get why you want to do this, but is there any proof that it's necessary? Something that is obviously broken without it? Otherwise I'm wondering whether maybe Netflix code covers this scenario already somewhere.

P.S. you probably need to rebase your branch and re-push to clean up the history.

@denyska denyska force-pushed the bug/non_closed_stream branch 2 times, most recently from d926c9b to deaf62e Compare July 21, 2016 21:50
@denyska
Copy link
Author

denyska commented Jul 21, 2016

@dsyer Zuul advocates writing custom filters and I assume a lot of people do it. In my case I have custom POST filter that massages response headers before they hit wire. Unfortunately I had sneaky NPE in that filter that was not logged (another topic to talk about, but Zuul logging has room to improve) and instead was masked with ConnectionPoolTimeoutException hundreds requests later.

at org.springframework.cloud.netflix.zuul.filters.route.apache.HttpClientRibbonCommand.run(HttpClientRibbonCommand.java:99)
    at org.springframework.cloud.netflix.zuul.filters.route.apache.HttpClientRibbonCommand.run(HttpClientRibbonCommand.java:43)
    at com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:293)
    at com.netflix.hystrix.HystrixCommand$1.call(HystrixCommand.java:289)
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46)
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.Observable.unsafeSubscribe(Observable.java:8460)
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51)
    at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
    at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
    at rx.Observable.unsafeSubscribe(Observable.java:8460)
    at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56)
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47)
    at org.springframework.cloud.sleuth.instrument.hystrix.SleuthHystrixConcurrencyStrategy$HystrixTraceCallable.call(SleuthHystrixConcurrencyStrategy.java:140)
    at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69)
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 common frames omitted
Caused by: java.lang.RuntimeException: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
    at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:456)
    at rx.observables.BlockingObservable.single(BlockingObservable.java:332)

@spencergibb
Copy link
Member

Closing due to inactivity. Please re-open if there's more to discuss

@spencergibb spencergibb closed this Oct 4, 2016
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 this pull request may close these issues.

None yet

3 participants