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

RetrofitFactory not thread safe #15

Open
mathieu-rolland opened this issue Feb 12, 2024 · 0 comments
Open

RetrofitFactory not thread safe #15

mathieu-rolland opened this issue Feb 12, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mathieu-rolland
Copy link

mathieu-rolland commented Feb 12, 2024

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();

    }
}
@ISAAC-XXYYZZ ISAAC-XXYYZZ self-assigned this Aug 12, 2024
@ISAAC-XXYYZZ ISAAC-XXYYZZ added the bug Something isn't working label Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants