RFR: 2182: Throw UncheckedRestException on empty GET responses
Erik Joelsson
erikj at openjdk.org
Fri Feb 23 21:50:52 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.
-------------
Commit messages:
- SKARA-2182
Changes: https://git.openjdk.org/skara/pull/1614/files
Webrev: https://webrevs.openjdk.org/?repo=skara&pr=1614&range=00
Issue: https://bugs.openjdk.org/browse/SKARA-2182
Stats: 16 lines in 2 files changed: 14 ins; 0 del; 2 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