Commit 37aca85
Only calculate hex string for valid HTTP responses (#6763)
* Add tests for Checksum hex validation and HTTP error handling
* Validate checksum HTTP responses and hex input
`Checksum.fromUri()` did not check the HTTP response status before
parsing the body as hex. When a proxy, CDN, or missing endpoint
returned an HTML/XML error page, `fromHex()` threw a cryptic
`NumberFormatException: For input string: "<?"`.
- Check `response.isSuccessful()` in `fromUri()` before parsing
- Trim response body to handle trailing newlines in checksum files
- Validate hex characters in `fromHex()` with a clear error message
- Catch failures in `DistributionInfos.fetchChecksum()` and return
null so the recipe proceeds without checksum verification
Fixes #6762
* Minimize API changes
* Remove unused import
---------
Co-authored-by: Tim te Beek <tim@mac.home>1 parent 2ae43a8 commit 37aca85
2 files changed
Lines changed: 54 additions & 0 deletions
File tree
- rewrite-core/src
- main/java/org/openrewrite
- test/java/org/openrewrite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| |||
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments