Skip to content

Commit 9100b13

Browse files
committed
Throw IOException instead of returning null
- remove superfluous check (was always false) - remove superfluous IOException - remove logger as it is no more needed See #292 (comment).
1 parent faddb48 commit 9100b13

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ public class JsonUtils {
7373
private static volatile CloseableHttpClient DEFAULT_HTTP_CLIENT;
7474
// Avoid possible endless loop when following alternate locations
7575
private static final int MAX_LINKS_FOLLOW = 20;
76-
private static final Logger log = LoggerFactory.getLogger(JsonUtils.class);
77-
7876

7977
static {
8078
// Disable default Jackson behaviour to close
@@ -371,18 +369,16 @@ private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpCli
371369
if (alternateLink != null) {
372370
linksFollowed++;
373371
if (linksFollowed > MAX_LINKS_FOLLOW) {
374-
log.warn("Too many alternate links followed. This may indicate a cycle. Aborting.");
375-
return null;
372+
throw new IOException("Too many alternate links followed. This may indicate a cycle. Aborting.");
376373
}
377-
return linksFollowed > MAX_LINKS_FOLLOW ? null
378-
: fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed);
374+
return fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed);
379375
}
380376
return fromInputStream(response.getEntity().getContent());
381377
}
382378
}
383379

384380
private static URL alternateLink(URL url, CloseableHttpResponse response)
385-
throws MalformedURLException, IOException {
381+
throws MalformedURLException {
386382
if (response.getEntity().getContentType() != null
387383
&& !response.getEntity().getContentType().getValue().equals("application/ld+json")) {
388384
for (Header header : response.getAllHeaders()) {

0 commit comments

Comments
 (0)