Skip to content

RetrofitFactory not thread safe #15

@mathieu-rolland

Description

@mathieu-rolland

Hi,

I encouter an issue when i call two times with different set of API KEY plug on 2 different account.
After some analyse, I found a not thread safe code in class com.kucoin.sdk.factory.RetrofitFactory.

The same instance will be return when an instance as already been generated.

The fix could be :

public class RetrofitFactory {

    private static final Converter.Factory CONVERTER_FACTORY = JacksonConverterFactory.create(KucoinObjectMapper.INSTANCE);

    public static Retrofit getPublicRetorfit(String baseUrl) {

        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(CONVERTER_FACTORY)
                .client(HttpClientFactory.getPublicClient())
                .build();

    }

    public static Retrofit getAuthRetorfit(String baseUrl, String apiKey, String secret, String passPhrase, Integer apiKeyVersion) {

        return new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(CONVERTER_FACTORY)
                .client(HttpClientFactory.getAuthClient(apiKey, secret, passPhrase, apiKeyVersion))
                .build();

    }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions