Repository navigation
Commit acbca8e
authored
fix: HTTP exception classification — separate permanent from retriable failures (#44)
## Summary
`HttpMessageDeliverer.deliver()` previously caught all exceptions as
`RetriableFailure`. This meant **corrupt delivery metadata or an unknown
service triggered an infinite retry loop** instead of moving the entry
to `FAILED`.
This PR classifies exceptions explicitly:
| Exception | Classification | Why |
|---|---|---|
| `JsonProcessingException` | `PermanentFailure` | Corrupt metadata
won't fix itself (caught before `IOException` — it's a subtype) |
| `IOException` | `RetriableFailure` | Connection / timeout — transient
|
| `InterruptedException` | `RetriableFailure` | Interrupt flag restored;
consistent with `KafkaMessageDeliverer` |
| other `Exception` | `PermanentFailure` | Malformed URI, unknown
service, `IllegalStateException` from `ServiceUrlResolver`, etc. |
## Why this matters
Before: `okapi-http` consumer with malformed JSON in `deliveryMetadata`
→ infinite retries → retry storm in logs, entry never marked `FAILED`,
operator alert fatigue.
After: corrupt input → `PermanentFailure` → entry moves to `FAILED` per
`RetryPolicy`, ops visibility preserved.
## Scope
- `HttpMessageDeliverer.kt`: refactor to expression-body, granular
`catch` blocks, updated KDoc
- `HttpMessageDelivererTest.kt`: 2 new tests
- corrupt metadata → `PermanentFailure` (does not throw)
- `urlResolver` throwing → `PermanentFailure` (does not throw)
Independent of the Kafka `deliverBatch` work in PR #40.
## Test plan
- [x] `./gradlew :okapi-http:test ktlintCheck` — all 13 unit tests pass
(11 existing + 2 new)1 parent fa9afda commit acbca8e
2 files changed
Lines changed: 47 additions & 25 deletions
File tree
- okapi-http/src
- main/kotlin/com/softwaremill/okapi/http
- test/kotlin/com/softwaremill/okapi/http
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
29 | | - | |
| 34 | + | |
30 | 35 | | |
31 | 36 | | |
32 | 37 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
58 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
93 | 104 | | |
0 commit comments