Skip to content

Commit

Permalink
fixed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Anubhav Gupta committed Sep 26, 2022
1 parent 3565f64 commit 90cea14
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ data class KeepAlive(
internal val isOptimal: Boolean = false
) {
companion object {
val NO_KEEP_ALIVE = KeepAlive(timeSeconds = -1, isOptimal = false)
val NO_KEEP_ALIVE = KeepAlive(timeSeconds = 60, isOptimal = false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MqttConnectOptions private constructor(
this.sslSocketFactory = Platform.get().newSslSocketFactory(x509TrustManager!!)
}

this.readTimeoutSecs = if (builder.readTimeoutSecs == DEFAULT_READ_TIMEOUT) {
this.readTimeoutSecs = if (builder.readTimeoutSecs < builder.keepAlive.timeSeconds) {
builder.keepAlive.timeSeconds + 60
} else {
builder.readTimeoutSecs
Expand Down Expand Up @@ -120,7 +120,7 @@ class MqttConnectOptions private constructor(
}

fun readTimeoutSecs(readTimeoutSecs: Int) = apply {
require(readTimeoutSecs > 0 || readTimeoutSecs == DEFAULT_READ_TIMEOUT) { "read timeout should be >= $DEFAULT_READ_TIMEOUT" }
require(readTimeoutSecs > 0) { "read timeout should be > 0" }
this.readTimeoutSecs = readTimeoutSecs
}

Expand Down Expand Up @@ -197,7 +197,7 @@ class MqttConnectOptions private constructor(
}

fun alpnProtocols(protocols: List<Protocol>) = apply {
require(protocols.isNotEmpty()) { "password cannot be empty" }
require(protocols.isNotEmpty()) { "alpn protocol list cannot be empty" }
this.protocols = protocols
}

Expand Down
6 changes: 0 additions & 6 deletions paho/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ plugins {
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
//kotlin("jvm")
}

//java {
// sourceCompatibility = JavaVersion.VERSION_1_8
// targetCompatibility = JavaVersion.VERSION_1_8
//}

dependencies {
implementation(deps.kotlin.stdlib.core)
implementation("com.squareup.okio:okio:3.2.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
*/
package org.eclipse.paho.client.mqttv3.internal.platform

import okio.Buffer
import org.eclipse.paho.client.mqttv3.Protocol
import org.eclipse.paho.client.mqttv3.internal.tls.BasicCertificateChainCleaner
import org.eclipse.paho.client.mqttv3.internal.tls.BasicTrustRootIndex
import org.eclipse.paho.client.mqttv3.internal.tls.CertificateChainCleaner
import org.eclipse.paho.client.mqttv3.internal.tls.TrustRootIndex
import org.eclipse.paho.client.mqttv3.readFieldOrNull
import java.io.IOException
import java.net.InetSocketAddress
import java.net.Socket
Expand All @@ -30,14 +37,6 @@ import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.TrustManager
import javax.net.ssl.TrustManagerFactory
import javax.net.ssl.X509TrustManager
import okio.Buffer
import org.eclipse.paho.client.mqttv3.Protocol
import org.eclipse.paho.client.mqttv3.internal.platform.android.AndroidLog
import org.eclipse.paho.client.mqttv3.internal.tls.BasicCertificateChainCleaner
import org.eclipse.paho.client.mqttv3.internal.tls.BasicTrustRootIndex
import org.eclipse.paho.client.mqttv3.internal.tls.CertificateChainCleaner
import org.eclipse.paho.client.mqttv3.internal.tls.TrustRootIndex
import org.eclipse.paho.client.mqttv3.readFieldOrNull

/**
* Access to platform-specific features.
Expand Down Expand Up @@ -91,7 +90,8 @@ open class Platform {
// platforms in order to support Robolectric, which mixes classes from both Android and the
// Oracle JDK. Note that we don't support HTTP/2 or other nice features on Robolectric.
val sslContextClass = Class.forName("sun.security.ssl.SSLContextImpl")
val context = readFieldOrNull(sslSocketFactory, sslContextClass, "context") ?: return null
val context =
readFieldOrNull(sslSocketFactory, sslContextClass, "context") ?: return null
readFieldOrNull(context, X509TrustManager::class.java, "trustManager")
} catch (e: ClassNotFoundException) {
null
Expand Down Expand Up @@ -223,7 +223,6 @@ open class Platform {
}

private fun findAndroidPlatform(): Platform {
AndroidLog.enable()
return Android10Platform.buildIfSupported() ?: AndroidPlatform.buildIfSupported()!!
}

Expand Down

This file was deleted.

0 comments on commit 90cea14

Please sign in to comment.