为什么改装OkHttpInterceptor中的tag()为null



请参阅代码:

接口:

/**
* This class is specific for entire cart module only
*/
interface ICartAPIService {
@GET(URLConstants.API_VERSION_V1 + URLConstants.API_URL_ADDTOCART)
suspend fun getCartData(@Tag test: String, @Query(URLConstants.API_URL_CUSTOMER_ID_1) value: String): Response<CartResponse>
}

从DataSource模块调用:

apiService.getCartData("mTag", getCustomerId())

拦截器:

override fun intercept(chain: Interceptor.Chain): Response {
val request: Request = chain.request()
val response = chain.proceed(request)
LogUtils.d("Hello tag: " + request.tag(Invocation::class.java))
LogUtils.d("Hello tag: " + request.tag())

结果:

你好标签:com.abc.service.remote.cart.ICartAPIService.getCartData(([mTag,5448852]

Hello标签:空

预期输出:

你好标签:mTag

这样解决:

val invocation: Invocation? = request.tag(Invocation::class.java)
if ((invocation?.arguments()?.size ?: 0) > 0) {
LogUtils.d("Hello test: " + invocation?.arguments()?.get(0))
}

相关内容

  • 没有找到相关文章

最新更新