Avoid crash (OOM) when content is too long.

This commit is contained in:
Benoit Marty 2024-09-23 09:11:39 +02:00
parent 5c7ac76c9a
commit 1802a2b7f1

View file

@ -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 {