RFR: 2182: Throw UncheckedRestException on empty GET responses [v2]
Erik Joelsson
erikj at openjdk.org
Wed Feb 28 19:06:02 UTC 2024
> A very common type of SEVERE logging message, which we get notifications for as admins, is this:
>
> Exception during periodic items checking: Cannot invoke "org.openjdk.skara.json.JSONArray.stream()" because the return value of "org.openjdk.skara.json.JSONValue.asArray()" is null
>
> There are some other kinds of instances where the NPE isn't providing any information, but that are likely caused by the same thing. From what I can tell, what's happening is that a REST GET call (typically to GitHub) returns an empty string in the response body. Our JSON parser translates this to a JSONNull and we subsequently try to treat it as a JSONArray and get the NPE when trying to call `stream()` on it. This typically happens a few times per day across all the bots. Ultimately I think this is a bug with GitHub, but we need to deal with it in a better way.
>
> My proposed solution is to add an option to RestRequest, `failOnEmptyResponse`, that defaults to true for GET requests but otherwise false. If set and the response body is empty, an UncheckedRestException is thrown. This exception is already handled as just a warning and we are collecting metrics for it to sound alarms if we get a lot of them.
Erik Joelsson has updated the pull request incrementally with three additional commits since the last revision:
- Only include the redirect in the RestException message if Location header is present
- Include Location in RestException message
- Improve logging of RestException
-------------
Changes:
- all: https://git.openjdk.org/skara/pull/1614/files
- new: https://git.openjdk.org/skara/pull/1614/files/a1527449..e72f3612
Webrevs:
- full: https://webrevs.openjdk.org/?repo=skara&pr=1614&range=01
- incr: https://webrevs.openjdk.org/?repo=skara&pr=1614&range=00-01
Stats: 6 lines in 2 files changed: 3 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/skara/pull/1614.diff
Fetch: git fetch https://git.openjdk.org/skara.git pull/1614/head:pull/1614
PR: https://git.openjdk.org/skara/pull/1614
More information about the skara-dev
mailing list