Skip to content

Commit 9cef1a1

Browse files
Update default subscription type and update auth interceptor to not handle all errors
1 parent 12d0433 commit 9cef1a1

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

stream-android-core/src/main/java/io/getstream/android/core/api/StreamClient.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ fun StreamClient(
259259
httpBuilder.apply {
260260
addInterceptor(StreamOkHttpInterceptors.clientInfo(clientInfoHeader))
261261
addInterceptor(StreamOkHttpInterceptors.apiKey(apiKey))
262-
addInterceptor(StreamOkHttpInterceptors.auth( "jwt", tokenManager, compositeSerialization))
263262
addInterceptor(StreamOkHttpInterceptors.connectionId(connectionIdHolder))
263+
addInterceptor(StreamOkHttpInterceptors.auth( "jwt", tokenManager, compositeSerialization))
264+
addInterceptor(StreamOkHttpInterceptors.error(compositeSerialization))
264265
}
265266
}
266267
configuredInterceptors.forEach {

stream-android-core/src/main/java/io/getstream/android/core/api/subscribe/StreamSubscriptionManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interface StreamSubscriptionManager<T> {
4444
*
4545
* @property retention Controls how the manager retains the listener reference.
4646
*/
47-
data class Options(val retention: Retention = Retention.AUTO_REMOVE) {
47+
data class Options(val retention: Retention = Retention.KEEP_UNTIL_CANCELLED) {
4848
/** Retention policy for a subscribed listener. */
4949
enum class Retention {
5050
/**

stream-android-core/src/main/java/io/getstream/android/core/internal/http/interceptor/StreamAuthInterceptor.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ internal class StreamAuthInterceptor(
8080

8181
if (parsed.isSuccess) {
8282
val error = parsed.getOrEndpointException("Failed to parse error body.")
83-
if (!alreadyRetried && isTokenInvalidErrorCode(error.code)) {
83+
84+
if (!isTokenInvalidErrorCode(error.code)) {
85+
return firstResponse
86+
}
87+
88+
if (!alreadyRetried) {
8489
// Refresh and retry once.
8590
firstResponse.close()
8691
tokenManager
@@ -104,12 +109,7 @@ internal class StreamAuthInterceptor(
104109
firstResponse.close()
105110
throw StreamEndpointException("Failed request: ${original.url}", error, null)
106111
} else {
107-
// Couldn’t parse error, still fail in a consistent way.
108-
firstResponse.close()
109-
throw StreamEndpointException(
110-
"Failed to serialize response error body: ${original.url}",
111-
null,
112-
)
112+
return firstResponse
113113
}
114114
}
115115

0 commit comments

Comments
 (0)