From a3e5dc8e0d8a0bb9507030489a5b5de5f9d85747 Mon Sep 17 00:00:00 2001 From: Bruce - Thien Nguyen Date: Fri, 1 Jul 2022 15:08:37 +0700 Subject: [PATCH 1/4] [#217] Increase timeout in http client to 30 seconds --- .../co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt index 5ecf3c6e0..444f687f2 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt @@ -7,6 +7,7 @@ import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor +import java.util.concurrent.TimeUnit @Module @InstallIn(SingletonComponent::class) @@ -18,6 +19,10 @@ class OkHttpClientModule { addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) + connectTimeout(30, TimeUnit.SECONDS) + writeTimeout(30, TimeUnit.SECONDS) + readTimeout(30, TimeUnit.SECONDS) } - }.build() + } + .build() } From 2cb331a19a25e2a37770481887fa48f6174edc55 Mon Sep 17 00:00:00 2001 From: Bruce - Thien Nguyen Date: Fri, 1 Jul 2022 15:17:44 +0700 Subject: [PATCH 2/4] [#217] Fix detekt of magic number --- .../coroutine/di/modules/OkHttpClientModule.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt index 444f687f2..18c41677e 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt @@ -9,6 +9,10 @@ import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import java.util.concurrent.TimeUnit +private const val CONNECT_TIME_OUT = 30L +private const val WRITE_TIME_OUT = 30L +private const val READ_TIME_OUT = 30L + @Module @InstallIn(SingletonComponent::class) class OkHttpClientModule { @@ -19,9 +23,9 @@ class OkHttpClientModule { addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) - connectTimeout(30, TimeUnit.SECONDS) - writeTimeout(30, TimeUnit.SECONDS) - readTimeout(30, TimeUnit.SECONDS) + connectTimeout(CONNECT_TIME_OUT, TimeUnit.SECONDS) + writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS) + readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) } } .build() From 0de815efbe7b7811f7a5da67d4e86e4daf58e3e3 Mon Sep 17 00:00:00 2001 From: Bruce - Thien Nguyen Date: Fri, 1 Jul 2022 16:15:00 +0700 Subject: [PATCH 3/4] [#217] Delete redundant time out --- .../co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt index 18c41677e..36af171d6 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt @@ -9,8 +9,6 @@ import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import java.util.concurrent.TimeUnit -private const val CONNECT_TIME_OUT = 30L -private const val WRITE_TIME_OUT = 30L private const val READ_TIME_OUT = 30L @Module @@ -23,8 +21,6 @@ class OkHttpClientModule { addInterceptor(HttpLoggingInterceptor().apply { level = HttpLoggingInterceptor.Level.BODY }) - connectTimeout(CONNECT_TIME_OUT, TimeUnit.SECONDS) - writeTimeout(WRITE_TIME_OUT, TimeUnit.SECONDS) readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) } } From 02acc423f37620ee5794e848f84b19aa22f5e274 Mon Sep 17 00:00:00 2001 From: Bruce - Thien Nguyen Date: Fri, 1 Jul 2022 16:22:41 +0700 Subject: [PATCH 4/4] [#217] Revert enter new line --- .../co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt index 36af171d6..338d28f6c 100644 --- a/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt +++ b/CoroutineTemplate/app/src/main/java/co/nimblehq/coroutine/di/modules/OkHttpClientModule.kt @@ -23,6 +23,5 @@ class OkHttpClientModule { }) readTimeout(READ_TIME_OUT, TimeUnit.SECONDS) } - } - .build() + }.build() }