Skip to content

Commit 3f5802f

Browse files
authored
Removed: BODY_BYTE_COUNT limit from datafile response
production datafile size crossed 1MB (1000000 bytes to 1000107 bytes) so while reading the response body with BODY_BYTE_COUNT limit of 1000000 bytes, last 107 bytes were not getting read resulting in Invalid response body hence resulting in JSON parsing exception.
1 parent 2724ddf commit 3f5802f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main/kotlin/com/featurevisor/sdk/Instance+Fetch.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ internal suspend fun fetchDatafileContent(
8484
}
8585
}
8686

87-
const val BODY_BYTE_COUNT = 1000000L
8887
private val client = OkHttpClient()
8988

9089
private suspend fun fetchDatafileContentFromUrl(
@@ -135,8 +134,8 @@ private suspend fun fetchWithRetry(
135134
val call = client.newCall(request)
136135
try {
137136
val response = call.execute()
138-
val responseBody = response.peekBody(BODY_BYTE_COUNT)
139-
val responseBodyString = responseBody.string()
137+
val responseBody = response.body
138+
val responseBodyString = responseBody?.string().orEmpty()
140139
if (response.isSuccessful) {
141140
val json = Json { ignoreUnknownKeys = true }
142141
FeaturevisorInstance.companionLogger?.debug(responseBodyString)

0 commit comments

Comments
 (0)