@@ -34,11 +34,11 @@ class TierCalculationService(
34
34
mapOf (" crn" to crn, " reason" to reason),
35
35
)
36
36
} catch (e: Exception ) {
37
- log.error(" Unable to remove tier calculations for $crn " )
38
37
telemetryService.trackEvent(
39
38
TIER_CALCULATION_REMOVAL_FAILED ,
40
39
mapOf (" crn" to crn, " reasonToDelete" to reason, " failureReason" to e.message),
41
40
)
41
+ throw e
42
42
}
43
43
44
44
fun calculateTierForCrn (crn : String , recalculationSource : RecalculationSource , allowUpdates : Boolean ) {
@@ -59,18 +59,15 @@ class TierCalculationService(
59
59
)
60
60
}
61
61
} catch (e: Exception ) {
62
- if (e is DataIntegrityViolationException ) {
63
- log.error(" Multiple concurrent attempts to calculate tier for $crn => $recalculationSource " )
64
- return
65
- }
66
62
val eventType = if (allowUpdates) TIER_CALCULATION_FAILED else TIER_RECALCULATION_DRY_RUN_FAILURE
67
63
telemetryService.trackEvent(
68
64
eventType,
69
65
mapOf (
70
66
" crn" to crn,
71
67
" exception" to e.message,
72
68
" recalculationSource" to recalculationSource::class .simpleName,
73
- " recalculationReason" to if (recalculationSource is RecalculationSource .EventSource ) recalculationSource.type else " "
69
+ " recalculationReason" to if (recalculationSource is RecalculationSource .EventSource ) recalculationSource.type else " " ,
70
+ " duplicateAttempt" to (e is DataIntegrityViolationException ).toString()
74
71
),
75
72
)
76
73
if (allowUpdates) {
@@ -80,10 +77,10 @@ class TierCalculationService(
80
77
}
81
78
82
79
private fun checkForCrnNotFound (crn : String , e : Exception ) {
83
- if (e is CrnNotFoundException ) {
84
- deleteCalculationsForCrn(crn, " Not Found in Delius " )
85
- } else {
86
- throw e
80
+ when (e) {
81
+ is DataIntegrityViolationException -> return
82
+ is CrnNotFoundException -> deleteCalculationsForCrn(crn, " Not Found in Delius " )
83
+ else -> throw e
87
84
}
88
85
}
89
86
@@ -138,8 +135,4 @@ class TierCalculationService(
138
135
).toMap()
139
136
140
137
private fun NeedSection.mapSeverity (): Pair <Need , NeedSeverity >? = severity?.let { section to it }
141
-
142
- companion object {
143
- private val log = LoggerFactory .getLogger(this ::class .java)
144
- }
145
138
}
0 commit comments