From aa447cd45ee3f439b7cf63544ba6d1a864569648 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 7 Jun 2023 19:26:31 +0200 Subject: [PATCH 1/3] Fix freezing when fetching IBSN and no results are found Fixes part of https://github.com/JabRef/jabref/issues/9979 --- CHANGELOG.md | 1 + .../logic/importer/fetcher/isbntobibtex/IsbnFetcher.java | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 912e08ad5fc..4325f44b237 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,6 +102,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - 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 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..768f71d1fcc 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,6 +2,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Optional; import java.util.regex.Pattern; @@ -69,8 +70,10 @@ public Optional performSearchById(String identifier) throws FetcherExc LOGGER.debug("Try using the alternate ISBN fetchers to find an entry."); } } finally { - while (bibEntry.isEmpty() && retryIsbnFetcher.iterator().hasNext()) { - AbstractIsbnFetcher fetcher = retryIsbnFetcher.iterator().next(); + // 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=" + identifier + "; trying " + fetcher.getName() + " next."); bibEntry = fetcher.performSearchById(identifier); } From 14ccb02f5996fd33122a7ebecf00f8e91b79751b Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 8 Jun 2023 06:25:20 +0200 Subject: [PATCH 2/3] Modernize IsbnFetcher --- .../importer/fetcher/isbntobibtex/IsbnFetcher.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 768f71d1fcc..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 @@ -4,6 +4,7 @@ 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; @@ -63,24 +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 { + 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=" + identifier + "; trying " + fetcher.getName() + " 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; @@ -97,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; } From cdbd9923ac97c23e14929d826dd6a282a1d50ad5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 8 Jun 2023 06:26:00 +0200 Subject: [PATCH 3/3] Add missing dots --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4325f44b237..a4d47c9815a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,13 +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 fetching an ISBN could lead to application freezing when the fetcher did not return any results [#9979](https://github.com/JabRef/jabref/issues/9979) +- 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