diff --git a/CHANGELOG.md b/CHANGELOG.md index 912e08ad5fc..a4d47c9815a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,12 +96,13 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue in the preferences where custom columns could be added to the entry table with no qualifier. [#9913](https://github.com/JabRef/jabref/issues/9913) - We fixed an issue where the encoding header in a bib file was not respected when the file contained a BOM (Byte Order Mark). [#9926](https://github.com/JabRef/jabref/issues/9926) - We fixed an issue where cli help output for import and export format was inconsistent. [koppor#429](https://github.com/koppor/jabref/issues/429) -- We fixed an issue where no preview could be generated for some entry types and led to an exception [#9947](https://github.com/JabRef/jabref/issues/9947) +- We fixed an issue where no preview could be generated for some entry types and led to an exception. [#9947](https://github.com/JabRef/jabref/issues/9947) - We fixed an issue where the Linux terminal working directory argument was malformed and therefore ignored upon opening a terminal [#9953](https://github.com/JabRef/jabref/issues/9953) -- We fixen an issue under Linux where under some systems the file instead of the folder was opened [#9607](https://github.com/JabRef/jabref/issues/9607) +- We fixen an issue under Linux where under some systems the file instead of the folder was opened. [#9607](https://github.com/JabRef/jabref/issues/9607) - We fixed an issue where an Automatic Keyword Group could not be deleted in the UI. [#9778](https://github.com/JabRef/jabref/issues/9778) - We fixed an issue where the citation key pattern `[edtrN_M]` returned the wrong editor. [#9946](https://github.com/JabRef/jabref/pull/9946) -- We fixed an issue where empty grey containers would remain in the groups panel, if displaying of group item count is turned off [#9972](https://github.com/JabRef/jabref/issues/9972) +- We fixed an issue where empty grey containers would remain in the groups panel, if displaying of group item count is turned off. [#9972](https://github.com/JabRef/jabref/issues/9972) +- We fixed an issue where fetching an ISBN could lead to application freezing when the fetcher did not return any results. [#9979](https://github.com/JabRef/jabref/issues/9979) ### Removed diff --git a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java index 579f13a7580..04062621325 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/isbntobibtex/IsbnFetcher.java @@ -2,7 +2,9 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.regex.Pattern; @@ -62,22 +64,23 @@ public Optional performSearchById(String identifier) throws FetcherExc identifier = removeNewlinesAndSpacesFromIdentifier(identifier); bibEntry = openLibraryIsbnFetcher.performSearchById(identifier); } catch (FetcherException ex) { + LOGGER.debug("Got a fetcher exception for IBSN search", ex); if (retryIsbnFetcher.isEmpty()) { throw ex; - } else { - LOGGER.debug("Got a fetcher exception for IBSN search", ex); - LOGGER.debug("Try using the alternate ISBN fetchers to find an entry."); } } finally { - while (bibEntry.isEmpty() && retryIsbnFetcher.iterator().hasNext()) { - AbstractIsbnFetcher fetcher = retryIsbnFetcher.iterator().next(); - LOGGER.debug("No entry found for ISBN=" + identifier + "; trying " + fetcher.getName() + " next."); + LOGGER.debug("Trying using the alternate ISBN fetchers to find an entry."); + // do not move the iterator in the loop as this would always return a new one and thus create and endless loop + Iterator iterator = retryIsbnFetcher.iterator(); + while (bibEntry.isEmpty() && iterator.hasNext()) { + AbstractIsbnFetcher fetcher = iterator.next(); + LOGGER.debug("No entry found for ISBN {}; trying {} next.", identifier, fetcher.getName()); bibEntry = fetcher.performSearchById(identifier); } } if (bibEntry.isEmpty()) { - LOGGER.debug("Could not found a entry for ISBN=" + identifier); + LOGGER.debug("Could not found a entry for ISBN {}", identifier); } return bibEntry; @@ -94,9 +97,7 @@ public List performSearch(BibEntry entry) throws FetcherException { } public IsbnFetcher addRetryFetcher(AbstractIsbnFetcher retryFetcher) { - if (retryFetcher == null) { - throw new IllegalArgumentException("Please provide a valid isbn fetcher."); - } + Objects.requireNonNull(retryFetcher, "Please provide a valid isbn fetcher."); retryIsbnFetcher.add(retryFetcher); return this; }