From c024403f9a11df14e7bd7b448678bde23c780c85 Mon Sep 17 00:00:00 2001 From: David Jirovec Date: Tue, 15 Dec 2020 10:01:11 +0100 Subject: [PATCH] Fix api init --- .../sdk/rest/impl/retrofit/AuthRetrofitAPIImpl.java | 11 +++++------ .../rest/impl/retrofit/PublicRetrofitAPIImpl.java | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/kucoin/sdk/rest/impl/retrofit/AuthRetrofitAPIImpl.java b/src/main/java/com/kucoin/sdk/rest/impl/retrofit/AuthRetrofitAPIImpl.java index 4d48fc1..b8c1551 100644 --- a/src/main/java/com/kucoin/sdk/rest/impl/retrofit/AuthRetrofitAPIImpl.java +++ b/src/main/java/com/kucoin/sdk/rest/impl/retrofit/AuthRetrofitAPIImpl.java @@ -3,24 +3,23 @@ */ package com.kucoin.sdk.rest.impl.retrofit; -import java.lang.reflect.ParameterizedType; - import com.kucoin.sdk.factory.RetrofitFactory; +import java.lang.reflect.ParameterizedType; + /** * Created by chenshiwei on 2019/1/10. */ public class AuthRetrofitAPIImpl extends AbstractRetrofitAPIImpl { - private volatile boolean inited; - private T apiImpl; + private volatile T apiImpl; @Override public T getAPIImpl() { - if (inited) + if (apiImpl != null) return apiImpl; synchronized (getClass()) { - if (inited) + if (apiImpl != null) return apiImpl; @SuppressWarnings("unchecked") Class tClass = (Class) ((ParameterizedType) this.getClass().getGenericSuperclass()) diff --git a/src/main/java/com/kucoin/sdk/rest/impl/retrofit/PublicRetrofitAPIImpl.java b/src/main/java/com/kucoin/sdk/rest/impl/retrofit/PublicRetrofitAPIImpl.java index e2f77b8..3c7640a 100644 --- a/src/main/java/com/kucoin/sdk/rest/impl/retrofit/PublicRetrofitAPIImpl.java +++ b/src/main/java/com/kucoin/sdk/rest/impl/retrofit/PublicRetrofitAPIImpl.java @@ -3,24 +3,23 @@ */ package com.kucoin.sdk.rest.impl.retrofit; -import java.lang.reflect.ParameterizedType; - import com.kucoin.sdk.factory.RetrofitFactory; +import java.lang.reflect.ParameterizedType; + /** * Created by chenshiwei on 2019/1/10. */ public class PublicRetrofitAPIImpl extends AbstractRetrofitAPIImpl { - private volatile boolean inited; - private T apiImpl; + private volatile T apiImpl; @Override public T getAPIImpl() { - if (inited) + if (apiImpl != null) return apiImpl; synchronized (getClass()) { - if (inited) + if (apiImpl != null) return apiImpl; @SuppressWarnings("unchecked") Class tClass = (Class) ((ParameterizedType) this.getClass().getGenericSuperclass()) @@ -30,4 +29,4 @@ public T getAPIImpl() { return t; } } -} \ No newline at end of file +}