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

[JAVA] Memory leak, stack overflow and incorrect callbacks with okhttp-gson #8915

Open
mpartel opened this issue Nov 14, 2018 · 1 comment
Open

Comments

@mpartel
Copy link

mpartel commented Nov 14, 2018

Description

In Java/libraries/okhttp-gson/api.mustache, the following lines add interceptors that never get removed:

if(progressListener != null) {
  apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
    ...

They pile up until the interceptor chain eventually causes a stack overflow.

Also, different interceptors from different requests get mixed up, making new requests invoke callbacks on previous requests.

Also, this makes the generated class thread-unsafe.

Progress listeners get added whenever an API callback is given, so this doesn't just happen to (the presumably rare) users who implement progress bars.

Swagger-codegen version

The library I'm using was generated with 2.3.0-SNAPSHOT I believe.
The code is unchanged in master.

Steps to reproduce

Make lots of ...Async() calls with a non-null callback parameter on the same api object.

Suggest a fix/enhancement

I don't see a way to add interceptors to individual requests in okhttp, so I guess a single interceptor should be made to look up (using Request.tag perhaps) which callback it needs to call.

@ngaya-ll
Copy link

See also: #7876
Proposed fix: #8053

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

No branches or pull requests

2 participants