Leku icon indicating copy to clipboard operation
Leku copied to clipboard

NetworkClient.java line 39 (Caused by java.io.InterruptedIOException: thread interrupted)

Open dhaval951753 opened this issue 2 years ago • 0 comments

Please provide proper solution for this issue:

fun requestFromLocationName(request: String): String? { var result: String? = null var stream: InputStream? = null var connection: HttpsURLConnection? = null try { val url = URL(request) Log.e("GeocodingUrl--", "" + request) connection = url.openConnection() as HttpsURLConnection connection.readTimeout = READ_TIMEOUT connection.connectTimeout = CONNECT_TIMEOUT connection.requestMethod = "GET" connection.doInput = true connection.connect()

        **val responseCode = connection.responseCode**
        if (responseCode != HttpsURLConnection.HTTP_OK) {
            throw NetworkException("HTTP error code: $responseCode")
        }
        stream = connection.inputStream
        if (stream != null) {
            result = readStream(stream, REPONSE_MAX_LENGTH)
        }
    } catch (ignore: UnknownHostException) {
    } catch (ioException: IOException) {
        throw NetworkException(ioException)
    } finally {
        if (stream != null) {
            try {
                stream.close()
            } catch (ioException: IOException) {
                throw NetworkException(ioException)
            }
        }
        connection?.disconnect()
    }
    return result
}

dhaval951753 avatar Nov 22 '21 08:11 dhaval951753