From 68106968d25a29ddfc0d32fd99122f6308b16b82 Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Mon, 22 Jan 2024 15:51:09 +0100 Subject: [PATCH] fix: reduce log level when unable to read from cached request This is normal for GET requests and should not cause panic attacks when reading the logs. --- .../lapis/util/CachedBodyHttpServletRequest.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lapis2/src/main/kotlin/org/genspectrum/lapis/util/CachedBodyHttpServletRequest.kt b/lapis2/src/main/kotlin/org/genspectrum/lapis/util/CachedBodyHttpServletRequest.kt index 8b2ae0cc..4fdcaf09 100644 --- a/lapis2/src/main/kotlin/org/genspectrum/lapis/util/CachedBodyHttpServletRequest.kt +++ b/lapis2/src/main/kotlin/org/genspectrum/lapis/util/CachedBodyHttpServletRequest.kt @@ -9,6 +9,7 @@ import jakarta.servlet.ServletInputStream import jakarta.servlet.http.HttpServletRequest import jakarta.servlet.http.HttpServletRequestWrapper import mu.KotlinLogging +import org.springframework.http.HttpMethod import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.IOException @@ -57,15 +58,17 @@ class CachedBodyHttpServletRequest(request: HttpServletRequest, val objectMapper } if (contentLength == 0) { - log.warn { "Could not read from request body, because content length is 0." } + log.debug { "Could not read from request body, because content length is 0." } return emptyMap() } return try { objectMapper.readValue(inputStream) } catch (exception: Exception) { - log.error { "Failed to read from request body: ${exception.message}" } - log.debug { exception.stackTraceToString() } + if (method != HttpMethod.GET.name()) { + log.warn { "Failed to read from request body: ${exception.message}, contentLength $contentLength" } + log.debug { exception.stackTraceToString() } + } emptyMap() } }