Skip to content

Commit

Permalink
Fix #372 Crash with Xiaomi on create Ktorfit.Builder (#375)
Browse files Browse the repository at this point in the history
* Fix #372 Crash with Xiaomi on create Ktorfit.Builder

* Update CHANGELOG.md

---------

Co-authored-by: Перевалов Данил <[email protected]>
  • Loading branch information
princeparadoxes and Перевалов Данил authored Jul 12, 2023
1 parent b25fcfc commit 845bb1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Deprecated
### Removed
### Fixed
#372 Crash with Xiaomi on create Ktorfit.Builder by @princeparadoxes

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public class Ktorfit private constructor(
*/
public class Builder {
private var _baseUrl: String = ""
private var _httpClient = HttpClient()
private var _httpClient: HttpClient? = null
private var _responseConverter: MutableSet<ResponseConverter> = mutableSetOf()
private var _suspendResponseConverter: MutableSet<SuspendResponseConverter> = mutableSetOf()
private var _requestConverter: MutableSet<RequestConverter> = mutableSetOf()
Expand Down Expand Up @@ -160,7 +160,7 @@ public class Ktorfit private constructor(
* Client-Builder that will be used for every request with object
*/
public fun httpClient(config: HttpClientConfig<*>.() -> Unit): Builder = apply {
this._httpClient = HttpClient(this._httpClient.engine, config)
this._httpClient = HttpClient(config)
}

/**
Expand Down Expand Up @@ -219,7 +219,7 @@ public class Ktorfit private constructor(
public fun build(): Ktorfit {
return Ktorfit(
baseUrl = _baseUrl,
httpClient = _httpClient,
httpClient = _httpClient ?: HttpClient(),
responseConverters = _responseConverter,
suspendResponseConverters = _suspendResponseConverter,
requestConverters = _requestConverter,
Expand Down

0 comments on commit 845bb1c

Please sign in to comment.