AdevintaSpain / Leku

:earth_africa: Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
https://adevintaspain.github.io/Leku/
Apache License 2.0
763 stars 170 forks source link

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

Closed dhaval951753 closed 1 year ago

dhaval951753 commented 2 years ago

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
}
ferranpons commented 1 year ago

Should be solved on the latest version