Skip to content

Commit a830ec0

Browse files
committed
Fix various Kotlin nullability errors
1 parent 2d514dc commit a830ec0

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

app/src/main/java/tech/httptoolkit/android/HttpToolkitApplication.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class HttpToolkitApplication : Application() {
248248
tryParseSemver(release.name)
249249
?: tryParseSemver(release.tag_name)
250250
?: throw RuntimeException("Could not parse release version ${release.tag_name}")
251-
val releaseDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(release.published_at)
251+
val releaseDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(release.published_at)!!
252252

253253
val installedVersion = getInstalledVersion(this@HttpToolkitApplication)
254254

app/src/main/java/tech/httptoolkit/android/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
457457
putExtra(PROXY_CONFIG_EXTRA, currentProxyConfig)
458458
})
459459
} else if (requestCode == SCAN_REQUEST && data != null) {
460-
val url = data.getStringExtra(SCANNED_URL_EXTRA)
460+
val url = data.getStringExtra(SCANNED_URL_EXTRA)!!
461461
launch { connectToVpnFromUrl(url) }
462462
}
463463
} else {

app/src/main/java/tech/httptoolkit/android/ProxyVpnRunnable.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class ProxyVpnRunnable(
7979
handler.handlePacket(packet)
8080
} catch (e: Exception) {
8181
Sentry.capture(e)
82-
Log.e(TAG, e.message)
82+
val errorMessage = e.message ?: e.toString()
83+
Log.e(TAG, errorMessage)
8384
}
8485

8586
packet.clear()

app/src/main/java/tech/httptoolkit/android/ProxyVpnService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ProxyVpnService : VpnService(), IProtectSocket {
6767
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
6868
currentService = this
6969
Log.i(TAG, "onStartCommand called")
70-
Log.i(TAG, if (intent.action != null) intent.action else "no action")
70+
Log.i(TAG, intent.action ?: "no action")
7171

7272
if (localBroadcastManager == null) {
7373
localBroadcastManager = LocalBroadcastManager.getInstance(this)
@@ -77,7 +77,7 @@ class ProxyVpnService : VpnService(), IProtectSocket {
7777
if (intent.action == START_VPN_ACTION) {
7878
val proxyConfig = intent.getParcelableExtra<ProxyConfig>(PROXY_CONFIG_EXTRA)
7979

80-
val vpnStarted = startVpn(proxyConfig)
80+
val vpnStarted = startVpn(proxyConfig!!)
8181

8282
if (vpnStarted) {
8383
// If the system briefly kills us for some reason (memory, the user, whatever) whilst

0 commit comments

Comments
 (0)