Skip to content

Commit c856b07

Browse files
authored
Merge pull request #11535 from Recherche-Data-Gouv/fix_infinite_loop_mdc_api_v2
MakeDataCount API may end up in infinite loop
2 parents 1507805 + d188361 commit c856b07

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/edu/harvard/iq/dataverse/api/MakeDataCountApi.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public Response updateCitationsForDataset(@PathParam("id") String id) throws IOE
160160
url = new URI(JvmSettings.DATACITE_REST_API_URL.lookup(pidProvider.getId()) +
161161
"/events?doi=" +
162162
authorityPlusIdentifier +
163-
"&source=crossref&page[size]=1000").toURL();
163+
"&source=crossref&page[size]=1000&page[cursor]=1").toURL();
164164
} catch (URISyntaxException e) {
165165
//Nominally this means a config error/ bad DATACITE_REST_API_URL for this provider
166166
logger.warning("Unable to create URL for " + persistentId + ", pidProvider " + pidProvider.getId());
@@ -175,11 +175,14 @@ public Response updateCitationsForDataset(@PathParam("id") String id) throws IOE
175175
int status = connection.getResponseCode();
176176
if (status != 200) {
177177
logger.warning("Failed to get citations from " + url.toString());
178+
connection.disconnect();
178179
return error(Status.fromStatusCode(status), "Failed to get citations from " + url.toString());
179180
}
180181
JsonObject report;
181182
try (InputStream inStream = connection.getInputStream()) {
182183
report = JsonUtil.getJsonObject(inStream);
184+
} finally {
185+
connection.disconnect();
183186
}
184187
JsonObject links = report.getJsonObject("links");
185188
JsonArray data = report.getJsonArray("data");

0 commit comments

Comments
 (0)