Skip to content

shortDOI formatter is very slow #10589

Closed

Description

In one of my libraries, which contains approx 100 DOI entries, having the shortDOI field formatter active noticeably slows down the time it takes to save the library.
It takes <1 second to save without said formatter, but 30-40 seconds with, during which JabRef becomes unresponsive. This happens on every save, even when all DOI fields are already in the shortDOI format.

@Override
public String format(String value) {
Objects.requireNonNull(value);
return DOI.parse(value)
.map(doi -> {
try {
return new ShortDOIService().getShortDOI(doi).getDOI();
} catch (ShortDOIServiceException e) {
LOGGER.error(e.getMessage(), e);
return value;
}
}).orElse(value);
}

public DOI getShortDOI(DOI doi) throws ShortDOIServiceException {
JSONObject responseJSON = makeRequest(doi);
String shortDoi = responseJSON.getString("ShortDOI");
return new DOI(shortDoi);
}

If I interpret the above pieces of code correctly, the formatter always makes a request to the shortDOI service, even if the DOI is already shortened. Would it be possible to first check if the DOI is already shortened (i.e. starts with "10/"), and only make a request if it is not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugConfirmed bugs or reports that are very likely to be bugsgood first issueAn issue intended for project-newcomers. Varies in difficulty.type: performance

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions