Skip to content

Commit

Permalink
Only RuntimeException cause transactions to rollback.
Browse files Browse the repository at this point in the history
  • Loading branch information
flexable777 committed Nov 21, 2024
1 parent 7048a64 commit 13ebe72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package no.nav.klage.oppgave.clients.gosysoppgave
import no.nav.klage.kodeverk.Tema
import no.nav.klage.oppgave.clients.gosysoppgave.OppgaveMapperResponse.OppgaveMappe
import no.nav.klage.oppgave.config.CacheWithJCacheConfiguration
import no.nav.klage.oppgave.exceptions.GosysOppgaveClientException
import no.nav.klage.oppgave.util.TokenUtil
import no.nav.klage.oppgave.util.getLogger
import no.nav.klage.oppgave.util.getSecureLogger
Expand Down Expand Up @@ -40,7 +41,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<GosysOppgaveRecord>()
.block() ?: throw OppgaveClientException("Oppgave could not be fetched")
.block() ?: throw RuntimeException("Oppgave could not be fetched")
}
}

Expand All @@ -62,7 +63,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<GosysOppgaveRecord>()
.block() ?: throw OppgaveClientException("Oppgave could not be updated")
.block() ?: throw RuntimeException("Oppgave could not be updated")
}
}

Expand All @@ -87,7 +88,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<OppgaveMapperResponse>()
.block() ?: throw OppgaveClientException("Could not get mapper for enhet")
.block() ?: throw RuntimeException("Could not get mapper for enhet")
}
}

Expand All @@ -110,7 +111,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<OppgaveMappe>()
.block() ?: throw OppgaveClientException("Could not get mapper for enhet")
.block() ?: throw RuntimeException("Could not get mapper for enhet")
}
}

Expand All @@ -136,7 +137,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<OppgaveListResponse>()
.block() ?: throw OppgaveClientException("Oppgaver could not be fetched")
.block() ?: throw RuntimeException("Oppgaver could not be fetched")
}

return oppgaveResponse.oppgaver
Expand All @@ -155,10 +156,10 @@ class GosysOppgaveClient(
ex.request?.uri ?: "-",
ex.responseBodyAsString
)
throw OppgaveClientException("Caught WebClientResponseException", ex)
throw GosysOppgaveClientException("Caught WebClientResponseException", ex)
} catch (rtex: RuntimeException) {
logger.warn("Caught RuntimeException", rtex)
throw OppgaveClientException("Caught runtimeexception", rtex)
throw GosysOppgaveClientException("Caught runtimeexception", rtex)
} finally {
val end: Long = System.currentTimeMillis()
logger.info("Method {} took {} millis", methodName, (end - start))
Expand All @@ -181,7 +182,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<List<Gjelder>>()
.block() ?: throw OppgaveClientException("Could not fetch gjelder kodeverk for tema ${tema.navn}")
.block() ?: throw RuntimeException("Could not fetch gjelder kodeverk for tema ${tema.navn}")
}

return gjelderResponse
Expand All @@ -203,7 +204,7 @@ class GosysOppgaveClient(
.header("Nav-Consumer-Id", applicationName)
.retrieve()
.bodyToMono<List<OppgavetypeResponse>>()
.block() ?: throw OppgaveClientException("Could not fetch oppgavetype kodeverk for tema ${tema.navn}")
.block() ?: throw RuntimeException("Could not fetch oppgavetype kodeverk for tema ${tema.navn}")
}

return oppgavetypeResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ enum class Status(val statusId: Long) {
}
}

class OppgaveClientException : Exception {
constructor(message: String?) : super(message)

constructor(message: String?, cause: Throwable?) : super(message, cause)
}

data class OppgaveMapperResponse(
val antallTreffTotalt: Int,
val mapper: List<OppgaveMappe>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ class EREGOrganizationNotFoundException(msg: String) : RuntimeException(msg)

class KodeverkNotFoundException(msg: String) : RuntimeException(msg)

class AttachmentCouldNotBeConvertedException(override val message: String = "FILE_COULD_NOT_BE_CONVERTED") : RuntimeException()
class AttachmentCouldNotBeConvertedException(override val message: String = "FILE_COULD_NOT_BE_CONVERTED") : RuntimeException()

class GosysOppgaveClientException : RuntimeException {
constructor(message: String?) : super(message)
constructor(message: String?, cause: Throwable?) : super(message, cause)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2340,7 +2340,7 @@ class BehandlingService(
return if (behandlingList.isEmpty()) {
null
} else if (behandlingList.size != 1) {
throw Exception("Found more than one behandling for gosysOppgaveId $gosysOppgaveId, investigate")
throw RuntimeException("Found more than one behandling for gosysOppgaveId $gosysOppgaveId, investigate")
} else {
behandlingList.first().id
}
Expand Down

0 comments on commit 13ebe72

Please sign in to comment.