Skip to content

Commit 27af635

Browse files
authored
build: update OkHttp to 5.3.0 stable (#9)
* build: update OkHttp 5.0.0-alpha.3 to 5.3.0 stable Move off the pre-release alpha to the current stable OkHttp 5.x line. 5.3.0 is the latest stable whose okhttp-android artifact still supports compileSdk 35 (5.4.0 requires minCompileSdk=36). The network-client API used (OkHttpClient, newCall/execute, Request.Builder, Credentials.basic, toMediaType/toRequestBody, HttpUrl) is stable across 5.x; no source changes. * refactor: replace okhttp3.internal.closeQuietly with local extension okhttp3.internal.closeQuietly is an unstable internal API. Replace it with a small private Closeable.closeQuietly() extension (same semantics) so the OkHttp upgrade path stays robust.
1 parent 9dadd24 commit 27af635

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ dependencies {
6565
implementation("com.blacksquircle.ui:language-base:2.6.0")
6666
implementation("com.blacksquircle.ui:language-json:2.6.0")
6767

68-
implementation("com.squareup.okhttp3:okhttp:5.0.0-alpha.3")
68+
implementation("com.squareup.okhttp3:okhttp:5.3.0")
6969
implementation("org.yaml:snakeyaml:2.3")
7070
implementation("com.github.daniel-stoneuk:material-about-library:3.2.0-rc01")
7171
implementation("com.jakewharton:process-phoenix:2.1.2")

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)