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 +}