Skip to content

Commit 3c311e7

Browse files
committed
refactor: replace okhttp3.internal.closeQuietly with local extension
okhttp3.internal.closeQuietly is an unstable internal API that could be removed in a future OkHttp patch without deprecation. Replace it with a small private Closeable.closeQuietly() extension (same semantics) so the OkHttp upgrade path stays robust.
1 parent eb31d36 commit 3c311e7

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ import moe.matsuri.nb4a.proxy.anytls.AnyTLSSettingsActivity
116116
import moe.matsuri.nb4a.proxy.config.ConfigSettingActivity
117117
import moe.matsuri.nb4a.proxy.shadowtls.ShadowTLSSettingsActivity
118118
import moe.matsuri.nb4a.ui.ConnectionTestNotification
119-
import okhttp3.internal.closeQuietly
119+
import java.io.Closeable
120120
import java.net.InetSocketAddress
121121
import java.net.Socket
122122
import java.net.UnknownHostException
@@ -2052,3 +2052,14 @@ class ConfigurationFragment @JvmOverloads constructor(
20522052
}
20532053

20542054
}
2055+
2056+
/**
2057+
* Closes this resource, ignoring any exception. Replacement for OkHttp's internal
2058+
* `closeQuietly()` extension so we don't depend on an unstable `okhttp3.internal` API.
2059+
*/
2060+
private fun Closeable.closeQuietly() {
2061+
try {
2062+
close()
2063+
} catch (_: Exception) {
2064+
}
2065+
}

0 commit comments

Comments
 (0)