Skip to content

Thread Safety #467

@damioune123

Description

@damioune123

Hello,

Is the Java client supposed to be thread-safe?

If I look at the generated code, there is a section that is not threadsafe :

if(progressListener != null) {
            apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
                @Override
                public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                    com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                    return originalResponse.newBuilder()
                    .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                    .build();
                }
            });
        }

apiClient.getHttpClient() is a shared OkHttpCLient, and networkInterceptors is an ArrayList.

So multiple thread calling API methods could end up trying to concurrently modify this ArrayList.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions