I just checked the code of processPagedQueryResults and I would modify it in the following way:
try {
//Get a single artifact by its URL
response = client.getResource(resultsUrl, OSLCConstants.CT_RDF);
boolean processed = false;
if (response != null) {
//De-serialize it as a Java object
if (asJavaObjects) {
//Requirement req = response.readEntity(Requirement.class);
//printRequirementInfo(req); //print a few attributes
} else {
//Just print the raw RDF/XML (or process the XML as desired)
processRawResponse(response);
processed = true;
}
}
if (!processed && response != null) {
// discard the result
response.readEntity(String.class);
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Unable to process artfiact at url: " + resultsUrl, e);
}
AFAIK, the idea is that the response must be processed even if you don’t need it. Sometimes, we had problems with just calling close (i.e. exceptions). I think AHC 5 also implements AutoCloseable to avoid dealing with these low-level details.
P.S. Jakarta Response does implement AutoCloseable but Java EE 7 JAX-RS doesn’t.