Skip to content

Commit 438d28b

Browse files
committed
Fix BlockingMethodInNonBlockingContext false positive
1 parent 9b84f2f commit 438d28b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/main/kotlin/com/lambda/client/manager/managers/NetworkManager.kt

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ package com.lambda.client.manager.managers
22

33
import com.lambda.client.manager.Manager
44
import com.lambda.client.util.threads.BackgroundScope
5-
import com.lambda.client.util.threads.defaultScope
6-
import kotlinx.coroutines.Dispatchers
7-
import kotlinx.coroutines.launch
85
import java.net.InetSocketAddress
96
import java.net.Socket
107

@@ -14,15 +11,14 @@ object NetworkManager : Manager {
1411

1512
init {
1613
BackgroundScope.launchLooping("offline", 1500L) {
17-
defaultScope.launch(Dispatchers.IO) {
18-
isOffline = try {
19-
Socket().use { socket ->
20-
socket.connect(InetSocketAddress("1.1.1.1", 80), 100)
21-
false
22-
}
23-
} catch (e: Exception) {
24-
true // Either timeout or unreachable or failed DNS lookup.
14+
@Suppress("BlockingMethodInNonBlockingContext")
15+
isOffline = try {
16+
Socket().use { socket ->
17+
socket.connect(InetSocketAddress("1.1.1.1", 80), 100)
18+
false
2519
}
20+
} catch (e: Exception) {
21+
true // Either timeout or unreachable or failed DNS lookup.
2622
}
2723
}
2824
}

0 commit comments

Comments
 (0)