Browse Source

Avoid crash (OOM) when content is too long.

pull/3515/head
Benoit Marty 4 weeks ago
parent
commit
1802a2b7f1
  1. 5
      libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt

5
libraries/network/src/main/kotlin/io/element/android/libraries/network/interceptors/FormattedJsonHttpLogger.kt

@ -34,6 +34,11 @@ internal class FormattedJsonHttpLogger( @@ -34,6 +34,11 @@ internal class FormattedJsonHttpLogger(
// It can be only the case if we log the bodies of Http requests.
if (level != HttpLoggingInterceptor.Level.BODY) return
if (message.length > 100_000) {
Timber.d("Content is too long (${message.length} chars) to be formatted as JSON")
return
}
if (message.startsWith("{")) {
// JSON Detected
try {

Loading…
Cancel
Save