diff --git a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java index 073dfdec361..daa55cb64b1 100644 --- a/src/main/java/org/jabref/logic/exporter/TemplateExporter.java +++ b/src/main/java/org/jabref/logic/exporter/TemplateExporter.java @@ -154,28 +154,21 @@ private Reader getReader(String filename) throws IOException { } else { dir = LAYOUT_PREFIX + (directory == null ? "" : directory + '/'); } - // Attempt to get a Reader for the file path given, either by // loading it as a resource (from within JAR), or as a normal file. If // unsuccessful (e.g. file not found), an IOException is thrown. String name = dir + filename; // Try loading as a resource first. This works for files inside the JAR: - - // If that did not work, try loading as a normal file URL: try { Path reso = Path.of(TemplateExporter.class.getResource(name).toURI()); - if (reso == null) { reso = Path.of(name); - } return Files.newBufferedReader(reso, StandardCharsets.UTF_8); - } catch (FileNotFoundException | URISyntaxException ex) { throw new IOException("Cannot find layout file: '" + name + "'."); } - } @Override diff --git a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java index 25f53a3a903..30f46b3b8b1 100644 --- a/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java +++ b/src/main/java/org/jabref/logic/protectedterms/ProtectedTermsParser.java @@ -51,7 +51,6 @@ private void readTermsList(Path path) { } try (Stream lines = Files.lines(path, StandardCharsets.UTF_8)) { this.terms.addAll(lines.map(this::setDescription).filter(line -> line != null).collect(Collectors.toList())); - } catch (IOException e) { LOGGER.warn("Could not read terms from file {}", path, e); } diff --git a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java index f0c6fce3fa7..01f59704af7 100644 --- a/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java +++ b/src/test/java/org/jabref/logic/protectedterms/ProtectedTermsLoaderTest.java @@ -167,8 +167,7 @@ void testAddNewTermListNewListInList(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), ProtectedTermsLoader.getInternalLists(), Collections.emptyList())); - ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", - tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); + ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); assertTrue(localLoader.getProtectedTermsLists().contains(newList)); } @@ -186,8 +185,7 @@ void testRemoveTermListReduceTheCount(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), ProtectedTermsLoader.getInternalLists(), Collections.emptyList())); - ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", - tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); + ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); localLoader.removeProtectedTermsList(newList); assertEquals(ProtectedTermsLoader.getInternalLists().size(), localLoader.getProtectedTermsLists().size()); } @@ -197,8 +195,7 @@ void testAddNewTermListSetsCorrectDescription(@TempDir Path tempDir) { ProtectedTermsLoader localLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(Collections.emptyList(), Collections.emptyList(), ProtectedTermsLoader.getInternalLists(), Collections.emptyList())); - ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", - tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); + ProtectedTermsList newList = localLoader.addNewProtectedTermsList("My new list", tempDir.resolve("MyNewList.terms").toAbsolutePath().toString()); assertEquals("My new list", newList.getDescription()); } }