Integrated: 2182: Throw UncheckedRestException on empty GET responses

Erik Joelsson erikj at openjdk.org
Thu Feb 29 22:03:13 UTC 2024


On Fri, 23 Feb 2024 21:47:07 GMT, Erik Joelsson <erikj at openjdk.org> wrote:

> 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.
> 
> Investigation and experimentation with this patch in our staging environment showed that these are (at least primarily) a mix of 302 and 304 responses. The 302 from JBS with a redirect to a maintenance page and 304 from GitHub for an unknown reason. We could have tried to handle every response code, or made >=300 errors, but for now I think the current approach is more straightforward and more likely to catch the problems we are specifically seeing. We are still logging the response codes so if we see other patterns in the future, we can adapt.

This pull request has now been integrated.

Changeset: dd8223ba
Author:    Erik Joelsson <erikj at openjdk.org>
URL:       https://git.openjdk.org/skara/commit/dd8223ba7577356bc3de0ae98d6843d071962cfa
Stats:     21 lines in 3 files changed: 17 ins; 0 del; 4 mod

2182: Throw UncheckedRestException on empty GET responses

Reviewed-by: zsong

-------------

PR: https://git.openjdk.org/skara/pull/1614


More information about the skara-dev mailing list