From f1b4b5be3d4c9d6467f6f5be7cdb193269862bfb Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 1 May 2019 14:30:14 +0200 Subject: [PATCH] Throw BibEntryNotFound exception in case entry is no longer present (#4935) * improve oo Logging * fix typos * Throw BibEntryNotFound exception in case entry is no longer present Fixes #4932 * add changelog * fix wording and move nonNullRequire to the top --- CHANGELOG.md | 1 + src/main/java/org/jabref/gui/openoffice/OOBibBase.java | 3 ++- src/main/java/org/jabref/logic/openoffice/OOBibStyle.java | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da78f32646..f711e4e8841 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where ranking an entry would generate an IllegalArgumentException. [#4754](https://github.com/JabRef/jabref/issues/4754) - We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767) - We fixed an issue where the RIS import would overwite the article date with the value of the acessed date [#4816](https://github.com/JabRef/jabref/issues/4816) +- We fixed an issue where an NullPointer exception was thrown when a referenced entry in an Open/Libre Office document was no longer present in the library. Now an error message with the reference marker of the missing entry is shown. [#4932](https://github.com/JabRef/jabref/issues/4932) diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java index 26cf2ee6b40..5e944a21e6e 100644 --- a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java +++ b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java @@ -518,7 +518,8 @@ private List refreshCiteMarkersInternal(List databases, OOB } else { LOGGER.info("BibTeX key not found: '" + keys[j] + '\''); LOGGER.info("Problem with reference mark: '" + names.get(i) + '\''); - cEntries[j] = new UndefinedBibtexEntry(keys[j]); + throw new BibEntryNotFoundException(names.get(i), Localization + .lang("Could not resolve BibTeX entry for citation marker '%0'.", names.get(i))); } } diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index 6a2be4584ba..34d3592f9dc 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -714,9 +714,13 @@ private String getAuthorYearInTextMarker(List entries, Map content = entry.getResolvedFieldOrAlias(s, database); if ((content.isPresent()) && !content.get().trim().isEmpty()) {