Skip to content

Commit ee858f4

Browse files
committed
Fix threading issue in abbreviate action
Fixes #12634
1 parent 619ac7f commit ee858f4

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
7575
- We fixed an issue where month values 21–24 (ISO 8601-2019 season codes) in Biblatex date fields were not recognized as seasons during parsing. [#12437](https://github.com/JabRef/jabref/issues/12437)
7676
- We fixed an issue where migration of "Search groups" would fail with an exception when the search query is invalid. [#12555](https://github.com/JabRef/jabref/issues/12555)
7777
- We fixed an issue where not all linked files from BibDesk in the field `bdsk-file-...` were parsed. [#12555](https://github.com/JabRef/jabref/issues/12555)
78-
- We fixed an issue where JabRef displayed an incorrect deletion notification when canceling entry deletion [#12645](https://github.com/JabRef/jabref/issues/12645)
78+
- We fixed an issue where JabRef displayed an incorrect deletion notification when canceling entry deletion. [#12645](https://github.com/JabRef/jabref/issues/12645)
79+
- We fixed an issue where an exception would occur when running abbreviate journals for multiple entries. [#12634](https://github.com/JabRef/jabref/issues/12634)
7980

8081
### Removed
8182

src/main/java/org/jabref/gui/journals/AbbreviateAction.java

+3-18
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,9 @@ private String abbreviate(BibDatabaseContext databaseContext, List<BibEntry> ent
104104

105105
NamedCompound ce = new NamedCompound(Localization.lang("Abbreviate journal names"));
106106

107-
// Collect all callables to execute in one collection.
108-
Set<Callable<Boolean>> tasks = entries.stream().<Callable<Boolean>>map(entry -> () ->
109-
FieldFactory.getJournalNameFields().stream().anyMatch(journalField ->
110-
undoableAbbreviator.abbreviate(databaseContext.getDatabase(), entry, journalField, ce)))
111-
.collect(Collectors.toSet());
112-
113-
// Execute the callables and wait for the results.
114-
List<Future<Boolean>> futures = HeadlessExecutorService.INSTANCE.executeAll(tasks);
115-
116-
// Evaluate the results of the callables.
117-
long count = futures.stream().filter(future -> {
118-
try {
119-
return future.get();
120-
} catch (InterruptedException | ExecutionException exception) {
121-
LOGGER.error("Unable to retrieve value.", exception);
122-
return false;
123-
}
124-
}).count();
107+
int count = entries.stream().mapToInt(entry ->
108+
(int) FieldFactory.getJournalNameFields().stream().filter(journalField ->
109+
undoableAbbreviator.abbreviate(databaseContext.getDatabase(), entry, journalField, ce)).count()).sum();
125110

126111
if (count == 0) {
127112
return Localization.lang("No journal names could be abbreviated.");

0 commit comments

Comments
 (0)