<commit_before>package com.vmenon.mpo.api.retrofit

import okhttp3.Interceptor
import okhttp3.Response
import java.net.SocketTimeoutException

class RetryInterceptor(private val maxRetries: Int) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        var currentAttempt = 0
        var response: Response? = null
        var currentDelay = 1000L
        val delayFactor = 2

        while (response == null) {
            try {
                response = chain.proceed(chain.request())
            } catch (timeoutException: SocketTimeoutException) {
                currentAttempt++
                if (currentAttempt < maxRetries) {
                    Thread.sleep(currentDelay)
                    currentDelay = (currentDelay * delayFactor)
                } else {
                    break
                }
            }
        }

        // Let final attempt just fall through
        return response ?: chain.proceed(chain.request())
    }
}<commit_msg>Adding ConnectExcepton to RetryInterceptor<commit_after>package com.vmenon.mpo.api.retrofit

import okhttp3.Interceptor
import okhttp3.Response
import java.net.ConnectException
import java.net.SocketTimeoutException

class RetryInterceptor(private val maxRetries: Int) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        var currentAttempt = 0
        var response: Response? = null
        var currentDelay = 1000L
        val delayFactor = 2

        while (response == null) {
            try {
                response = chain.proceed(chain.request())
            } catch (exception: Exception) {
                when (exception) {
                    is SocketTimeoutException, is ConnectException -> {
                        currentAttempt++
                        println("Going to retry with attempt $currentAttempt after delay of $currentDelay")
                        Thread.sleep(currentDelay)

                        if (currentAttempt < maxRetries) {
                            currentDelay = (currentDelay * delayFactor)
                        } else {
                            break
                        }
                    }
                    else -> throw exception
                }
            }
        }

        // Let final attempt just fall through
        return response ?: chain.proceed(chain.request())
    }
}
{'fraction_non_alphanumeric': 0.07160804020100503, 'fraction_numerical': 0.006700167504187605, 'mean_word_length': 1.6252747252747253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6990310', 'n_tokens_mistral': 592, 'n_tokens_neox': 540, 'n_words': 144}