Arpan Sarkar
04/11/2021, 1:12 PMjava.lang.ClassCastException: kotlin.Unit cannot be cast to kotlin.Result
when using useIR = true
Kotlin Version : 1.4.32
After upgrading to 1.4.32 all runCatching { }
call are throwing java.lang.ClassCastException
is there any bug or breaking changes in version 1.4.32 ?
As an example
suspend fun connect(clientId: String): Boolean {
if (isConnected) {
Timber.d("Already connected to broker ${mqttClient.serverURI}")
return true
}
mqttClient = MqttClient(BuildConfig.BROKER_URI, clientId, null)
mqttClient.setCallback(mqttCallback)
val result = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
runCatching {
Timber.d("Connecting to broker ${mqttClient.serverURI}")
val options = MqttConnectOptions().apply {
mqttVersion = MqttConnectOptions.MQTT_VERSION_3_1_1
isCleanSession = true
isAutomaticReconnect = true
maxReconnectDelay = 10000
}
mqttClient.connect(options)
Timber.d("Broker connected.")
}
}
result.exceptionOrNull()?.let { t ->
Timber.e(t, "Failed to connect to the broker.")
}
return result.isSuccess
}
rnett
04/11/2021, 8:28 PM