OkHttpClient.Builder Interceptor is added to retrofit 2,even condition is false
<p>I have a retrofit adapter in which i am attaching a interceptor of accestoken to every request only if the acesstoken is not null, but the interceptor is attached with every request.</p>

<p>My request is as follow,</p>

<pre><code>if(null!= ApplicationClass.getAccessToken())
        CLIENT.addInterceptor(new Interceptor() {
            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {
                Request request = chain.request().newBuilder().addHeader("authorization", ApplicationClass.getAccessToken()).build();
                return chain.proceed(request);
            }
        });
</code></pre>

<p>My Retrofit Adapter code is as follows,</p>

<pre><code>import android.support.annotation.NonNull;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.concurrent.TimeUnit;

import cl.tt.ApplicationClass;
import cl.tt.BuildConfig;
import cl.tt.modals.MActionDone;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.ResponseBody;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Converter;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;


public class RetrofitAdapters {
private static  OkHttpClient.Builder CLIENT;
private static String ROOT = BuildConfig.HOST + "/api/v1/";


static {
    CLIENT = new OkHttpClient().newBuilder();
    CLIENT.connectTimeout(1200, TimeUnit.SECONDS);
    CLIENT.readTimeout(1200, TimeUnit.SECONDS);
    CLIENT.writeTimeout(1200, TimeUnit.SECONDS);
}

@NonNull
public static &lt;S&gt; S createRetrofitService(Class&lt;S&gt; serviceClass) {
    return getRetrofit().create(serviceClass);
}

@NonNull
private static Retrofit getRetrofit() {

    if (BuildConfig.DEBUG) {
        HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
        interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        CLIENT.addInterceptor(interceptor);
    }

    if(null!= ApplicationClass.getAccessToken())
        CLIENT.addInterceptor(new Interceptor() {
            @Override
            public okhttp3.Response intercept(Chain chain) throws IOException {
                Request request = chain.request().newBuilder().addHeader("authorization", ApplicationClass.getAccessToken()).build();
                return chain.proceed(request);
            }
        });

    return new Retrofit.Builder()
            .baseUrl(ROOT)
            .addConverterFactory(JacksonConverterFactory.create())
            .client(CLIENT.build())
            .build();
}

public static MActionDone parseError(Response&lt;?&gt; response) {
    Converter&lt;ResponseBody, MActionDone&gt; converter =
            getRetrofit().responseBodyConverter(MActionDone.class, new Annotation[0]);

    MActionDone error;

    try {
        error = converter.convert(response.errorBody());
    } catch (IOException e) {
        return new MActionDone();
    }

    return error;
}
</code></pre>

<p>}</p>