Skip to content

Commit

Permalink
Try Jetty.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Dec 29, 2023
1 parent e7a7d59 commit 6e6e3c6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 40 deletions.
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-web") {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-tomcat")
}
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-jetty")

implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("javax.cache:cache-api")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package no.nav.klage.oppgave.config.problem

import jakarta.servlet.http.HttpServletRequest
//import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException
import no.nav.klage.dokument.exceptions.DokumentValidationException
import no.nav.klage.dokument.exceptions.JsonToPdfValidationException
import no.nav.klage.oppgave.exceptions.*
import no.nav.klage.oppgave.util.getSecureLogger
import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException
import org.springframework.http.HttpStatus
import org.springframework.http.ProblemDetail
import org.springframework.web.bind.annotation.ExceptionHandler
Expand All @@ -22,43 +21,43 @@ class ProblemHandlingControllerAdvice : ResponseEntityExceptionHandler() {
private val secureLogger = getSecureLogger()
}

@ExceptionHandler
fun catchISE(
ex: IllegalStateException,
request: NativeWebRequest
): ProblemDetail {
logger.debug("catching IllegalStateException", ex)

if (ex.cause is SizeLimitExceededException) {
return create(HttpStatus.PAYLOAD_TOO_LARGE, ex)
}

try {
val nativeRequest = request.nativeRequest

if (nativeRequest is HttpServletRequest) {
logger.debug("dispatcherType = " + nativeRequest.dispatcherType?.name)

logger.debug("path = " + nativeRequest.pathInfo)
logger.debug("requestURI = " + nativeRequest.requestURI)

if (nativeRequest.isAsyncStarted) {
logger.debug("asyncContext = " + nativeRequest.asyncContext)
}
}
} catch (e: Exception) {
logger.warn("problems with handling ISE", e)
}

return create(HttpStatus.INTERNAL_SERVER_ERROR, ex)
}

@ExceptionHandler
fun handleSizeLimitExceededException(
ex: SizeLimitExceededException,
request: NativeWebRequest
): ProblemDetail =
create(HttpStatus.PAYLOAD_TOO_LARGE, ex)
// @ExceptionHandler
// fun catchISE(
// ex: IllegalStateException,
// request: NativeWebRequest
// ): ProblemDetail {
// logger.debug("catching IllegalStateException", ex)
//
// if (ex.cause is SizeLimitExceededException) {
// return create(HttpStatus.PAYLOAD_TOO_LARGE, ex)
// }
//
// try {
// val nativeRequest = request.nativeRequest
//
// if (nativeRequest is HttpServletRequest) {
// logger.debug("dispatcherType = " + nativeRequest.dispatcherType?.name)
//
// logger.debug("path = " + nativeRequest.pathInfo)
// logger.debug("requestURI = " + nativeRequest.requestURI)
//
// if (nativeRequest.isAsyncStarted) {
// logger.debug("asyncContext = " + nativeRequest.asyncContext)
// }
// }
// } catch (e: Exception) {
// logger.warn("problems with handling ISE", e)
// }
//
// return create(HttpStatus.INTERNAL_SERVER_ERROR, ex)
// }
//
// @ExceptionHandler
// fun handleSizeLimitExceededException(
// ex: SizeLimitExceededException,
// request: NativeWebRequest
// ): ProblemDetail =
// create(HttpStatus.PAYLOAD_TOO_LARGE, ex)

@ExceptionHandler
fun handleFeilregistreringException(
Expand Down

0 comments on commit 6e6e3c6

Please sign in to comment.