Commit 395e12f
fix(sap-demo): /api/v1/audit returns 200 on empty audit table
GET /api/v1/audit returned 500 because the route wasn't registered and
Spring's fallback NoResourceFoundException was caught by the generic
@ExceptionHandler(Exception.class), masquerading as an internal server
error. The intuitive audit-centric path should just work, and unmapped
routes in general should 404 cleanly rather than 500.
Changes:
* AuditController exposes GET /api/v1/audit as the canonical route,
keeping GET /api/v1/customers/recent-views as a back-compat alias.
Null-safes the result list so an empty audit table still returns
`{"items":[],"count":0}` rather than falling through to Map.of's
NPE-on-null.
* GlobalExceptionHandler adds an explicit NoResourceFoundException
handler that returns 404 with an RFC 7807 body, so typos / probing
no longer surface as 500s.
Reproduction:
curl -i http://localhost:8080/api/v1/audit
→ HTTP 500 + "An unexpected error occurred"
Log: NoResourceFoundException: No static resource api/v1/audit.
Root cause:
Controller mapped at /api/v1/customers/recent-views; no route for
/api/v1/audit; Spring's static-resource fallback throws
NoResourceFoundException which the catch-all Exception handler treated
as a 500 (should be 404).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 70c76d2 commit 395e12f
2 files changed
Lines changed: 31 additions & 3 deletions
File tree
- sap-demo-java/src/main/java/com/tricentisdemo/sap/customer360/web
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
17 | 25 | | |
18 | | - | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
| |||
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | | - | |
| 39 | + | |
33 | 40 | | |
34 | | - | |
| 41 | + | |
35 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
80 | 98 | | |
81 | 99 | | |
82 | 100 | | |
| |||
0 commit comments